You're absolutely right, foxidrive, and I understand you're frustrated. Sorry about that. Thing is, some of the files and pathnames I'm shifting around are sensitive and I had to use discretion with names and paths.
Nonetheless, your code was indeed helpful and very much appreciated, and in fact I think it was the catalyst to helping me accomplish what I had set out to do originally.
Code: Select all
@ECHO OFF
SETLOCAL EnableDelayedExpansion
SET "SRC=A n B"
SET "DST=Y n Z"
if exist "FILESINLOOP-2.txt" del "FILESINLOOP-2.txt" 2>nul
::pushd "%src%"
FOR /F "delims=" %%a IN ('DIR /b /s /a-d "%SRC%"') DO (
ECHO %%a & ECHO.
SET "var2=%%~dpa"
SET "var2=!var2:%CD%\=!"
ECHO MD "%dst%\!var2!" 2>nul
ECHO.
ECHO %%~na >> "FILESINLOOP-2.txt"
ECHO MKLINK "%%~nxa" "%%a" & ECHO.
)
PAUSE
::popd
I ended up taking pushd/popd out as the MD command was creating the links inside of the source directory.
As the code stands, it seems like the script will now create a copy of the 'SRC' folder (A n B) inside the 'DST' directory (i.e. "%CD%\Y n Z\A n B\subdir1\etc..."), then maintain subdirectory structure from there.
You're absolutely right about batch, foxidrive, and I didn't mean to imply you weren't being helpful in any way. I just didn't want to be verbose about the specifics of the task simply because I thought others would gloss over the post and think "TL;DR" and move on, my bad.
Good to know that's not the case (I mean this is batch after all, specifics are paramount)!
Looking back, I probably could've done this easier with VBS as I find it easier, but I wanted to make sure there would be no anomalies running this on the server.
Thanks to both of you, I think this script should work. I'm gonna do a "dry run" of sorts on a local copy of the file structure to check it, then go from there.
Thank you both, sincerely, for taking the time to help me with what I'm sure you'd both describe as a fairly menial task.