I need help with this little bash-maneuvre
Hi all,
i'm a new user here and although i'm maybe not a real newbie, i didn't know which other of the forums to use, Software just didnt feel right.
Anyhow. I have files with identical names, eg "TheSong.mp3", spread out over dirs with similar names, eg "Folder01", "Folder02", "Folder03" etc.
Now i want to move all these files into the same folder, but in order to avoid too much fighting i figured i'd give them unique names.
My question concerns this renaming. Just by heart i thought maybe the parent folder, or should i say, the folder that the file resides in, could be a good name to add to the current filename. The result would be something like "Folder01_TheSong.mp3", "Folder02_TheSong.mp3", etc
I have this vague idea that i could position myself in root (just above the Folder0x) and use find to find the files, and then sortof pipe them through... well... xargs or something. Well not really piping. But if i remember correctly, xargs is used to do things on found files. Or, i could go a bit fancier perhaps and make some kind of for-loops that checks into each folder and does the dirty work. In any case, i'm gonna need some sort of reference to the folder-name. is there a variable such as $pwd that could be used?
All ideas are appreciated....
(.... but if you're gonna answer "RTFM" or "go to tldp.org" or something like that, please just ignore this post mmmmkay?)
Oh by the way, the folders are empty except for these files, one file in each folder.
peace!
|