I am quite new to Command Prompt (Windows), however I have used it to do some file extensions changing and it is extremely helpful. I know nothing on coding, and so i am simply going off what I have read about but I am looking for a command line that I cant seem to find anywhere. I have folder, and inside that folder are 70 sub folders each labelled by a number from 1-70. Inside these subfolders are roughly 20 png picture files, that are currently numbered by a number from 1-20 in png format. I am looking for a command line to rename each file from its original name to "folder name (page number).png"
For example, I have folder called '68' and inside that folder is 1.png, 2.png, 3.png. I want the command line to change that 1.png and 2.png etc... to 68 (1).png and 68 (2). png, noticing the space between the bracket and the folder name. Sorry if i have made it confusing but I would really appreciate it and I have got some very helpful and quick answers from StackOverflow before
Thankyou if you are able to help me, as i am completely hopeless on this matter.
A slight modification of the approach @foxidrive suggested, so the script can be run from anywhere and won't have to parse
dir
output:Note that this will not work in Windows XP (not sure about Windows Vista), due to a bug with the expansion of
*
in the innerfor
loop that would cause the files to be renamed multiple times.Only run this once - launch it from the folder containing the 70 folders.
I am not a very experienced bash scriptor, but I guess this should do the task for you. I am assuming that you are using Linux operating system. So open a text editor and copy the following:
save this script where you have you folders 1-70 (and call it whatever.ssh). Then open a terminal and write down
chmod a+x whatever.ssh
and after that./whatever.ssh
. This should do the job as you presented in your question.