toplevel\
toplevel\info.txt
toplevel\subdir-01\
toplevel\subdir-02\
toplevel\subdir-03\
I need to do 2 things.. The first is to create a 'readme' folder in each of the subdirs, and then copy info.txt from \toplevel\ to the 'readme' subdir.. so the end result would be:
toplevel\
toplevel\info.txt
toplevel\subdir-01\readme\info.txt
toplevel\subdir-02\readme\info.txt
toplevel\subdir-03\readme\info.txt
I tried chaining two scripts I already have into one, and it creates the 'readme' subdir, but fails on the file copying part, apparently it doesn't travel through the subdirs properly:
Code: Select all
@echo off
setLocal EnableDelayedExpansion
pushd d:\files
for /f "tokens=* delims= " %%a in ('dir/b/ad') do (
mkdir "%%a\readme"
)
for /f "delims=" %%a in ( ' dir "*.txt" /b /s /a-d ' ) do (
echo processing "%%a"
set "name=%%~nxa"
pushd "%%~dpa"
copy /b /y "%%a" ".\readme\!name:~0!"
popd
)
Thanks in advance for any help with this!