I'm trying to develop a batch script that will allow me to rename, delete and move files.
Step 1:
For each folder: delete "00.jpg" and "Credits.jpg" file.
FOR /D %%d IN (*) DO del %%d\00.jpg;del %%d\Credits.jpg
Step 2 (Where I'm stuck):
For each folder: retrieve the last 4 characters (XXXX).
Every file in each folder must be renamed to : XXXX + " (" + filename+")".jpg
For example: a_v18_c160\03.jpg -> a_v18_c160\c160 (03).jpg
Folder names can contain special characters: "["."]"."_","-" but always end with "c" plus three numbers.
Step 2.1(Optional):
Remove 0 if it's not necessary. For example: c160 (03).jpg -> c160 (3).jpg
Step 3:
Move files from every subfolder to root folder:
Example: Root Folder\a\c160 (02).jpg -> Root Folder\c160 (02).jpg
FOR /D %%d IN (*) DO move %%d\* "F:\Root Folder\"
Starting from something like this:
F:\Root Folder\a_v18_c160\00.jpg
F:\Root Folder\a_v18_c160\01.jpg
F:\Root Folder\a_v18_c160\02.jpg
F:\Root Folder\a_v18_c160\03.jpg
F:\Root Folder\a_v18_c160\Credits.jpg
F:\Root Folder\a_v18_c161\00.jpg
F:\Root Folder\a_v18_c161\01.jpg
F:\Root Folder\a_v18_c161\Credits.jpg
The result would be:
F:\Root Folder\c160 (01).jpg
F:\Root Folder\c160 (02).jpg
F:\Root Folder\c160 (03).jpg
F:\Root Folder\c161 (01).jpg
F:\Root Folder\a_v18_c160\
F:\Root Folder\a_v18_c161\
How can I perform step 2?