Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A few notes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A few notes
Authored by: lullabud on Feb 26, '13 09:48:32AM
To be safe, that "cp" really should be "cp -n" so you don't overwrite destination files with the same name. (eg: moving 1/foo.jpg 2/foo.jpg to the current directory would end up with just 2/foo.jpg as foo.jpg)

Another way to get all the files into the same dir is to change slashes to another character, like an underscore. Here's an example in bash: find . -type f | sed 's/^\.\///' | while read -r X ; do echo mv "${X}" "${X//\//_}" ; done ; # filesystem regex's always look wonky with slash delimiters

Yet another way to do massive renames like this is with one of my favorite perl scripts, prename. (You can find it by googling "perl prename") With prename, you could flatten a two-level directory like this: prename 's^/^_^g' */* # perl and many others now allow you to use something other than a slash regex delimiter, which is useful for filesystem operation legibility

[ Reply to This | # ]
A few notes
Authored by: excarnate on Mar 01, '13 02:15:57PM

You're moving, he is copying, big difference.



[ Reply to This | # ]