« |
Main
| »
May 20, 2010
I get annoyed when I copy a file using either a spiffy file system
tool -- like Finder or Explorer -- or an IDE that's not emacs it the
resulting file ends up with a rediculous name that ends with a number
or starts with Copy of -. Seroiusly, who in their right mind
would ever want to copy a file and have the resulting file actually
named something that begins with Copy of -. So, I propose
a smarter copying scheme that infers the repetion you'd like to do on
the name of a file and produces multiple copies using this idea. That
was a shitty explanation, but basically, if I give this
thing NorthUpLeft.txt, I don't want to get
out NorthUpLeft-1.txt or Copy of -
NorthUpLeft.txt; instead I probably would want a bunch of
copies for directions north, south, east
and west; also copies fo the directions up
and down; etc. Anyway, smart_cp
does this on the command line and is mindful of underscores, camel
case, and numbers. If the input file doesn't exist, it just prints
what it would copy. For example:
% ./smart_cp north.txt
north.txt
south.txt
east.txt
west.txt
or
% ./smart_cp north_north.txt
north_north.txt
south_north.txt
east_north.txt
west_north.txt
north_south.txt
south_south.txt
east_south.txt
west_south.txt
north_east.txt
south_east.txt
east_east.txt
west_east.txt
north_west.txt
south_west.txt
east_west.txt
or
% ./smart_cp NorthUpLeft1.txt
How many occurrences would you like> 3
NorthUpLeft1.txt
NorthUpLeft2.txt
NorthUpLeft3.txt
NorthUpRight1.txt
NorthUpRight2.txt
NorthUpRight3.txt
NorthDownLeft1.txt
NorthDownLeft2.txt
NorthDownLeft3.txt
NorthDownRight1.txt
NorthDownRight2.txt
NorthDownRight3.txt
SouthUpLeft1.txt
SouthUpLeft2.txt
SouthUpLeft3.txt
SouthUpRight1.txt
SouthUpRight2.txt
SouthUpRight3.txt
SouthDownLeft1.txt
SouthDownLeft2.txt
SouthDownLeft3.txt
SouthDownRight1.txt
SouthDownRight2.txt
SouthDownRight3.txt
EastUpLeft1.txt
EastUpLeft2.txt
EastUpLeft3.txt
EastUpRight1.txt
EastUpRight2.txt
EastUpRight3.txt
EastDownLeft1.txt
EastDownLeft2.txt
EastDownLeft3.txt
EastDownRight1.txt
EastDownRight2.txt
EastDownRight3.txt
WestUpLeft1.txt
WestUpLeft2.txt
WestUpLeft3.txt
WestUpRight1.txt
WestUpRight2.txt
WestUpRight3.txt
WestDownLeft1.txt
WestDownLeft2.txt
WestDownLeft3.txt
WestDownRight1.txt
WestDownRight2.txt
WestDownRight3.txt
This probably involves finding a fix point or something, I don't know.
Posted by jeff at May 20, 2010 08:00 AM