I have a directory structure that looks like this:
Folder A
A.PDF
A_1.TIF
A_2.TIF
A_3.TIF
Folder B
B.PDF
B_1.TIF
B_2.TIF
B_3.TIF
Folder C
C.PDF
C_1.TIF
C_2.TIF
C_3.TIF
What I want to be able to do is have it so a script sorts the PDFs and TIFFs into separate folders with a specific title, for example:
Folder A
Representation_1
A.PDF
Preservation_1
A_1.TIF
A_2.TIF
A_3.TIF
I've used the following script to read the names of the files and sort them into new folders based off a string in their filename. I was hoping it could be retrofitted to do the same, but using file extensions:
@echo off
setlocal EnableDelayedExpansion
REM Put here the path where the files are:
set "Source=%~dp0"
for %%a in ("%Source%\*") do (
set "File=%%~na"
for /d %%b in ("%Source%\*") do (
set "Folder=%%~nb"
If "!File:~0,18!"=="!Folder:~0,18!" Move "%%a" "%%b"
)
if Exist "%%a" md "!Source!\!File:~0,18!"& move /y "%%a" "!Source!\!File:~0,18!"
)
