armstrongnt
asked on
Vbs script to create Directories and move files to directory
I have bunch of files
0010.txt
001.txt
asd0.txt
0030.txt
0040.txt
0050.txt
vbs script should create folder structure like this for for every individual file
for 0010.txt
0010 \components
\notes
\version
\workshop\0010_workshop_00 01.txt
0010.txt should be copied to 0010 \workshop\ and should be renamed 0010_workshop_0001.txt
the complete path of the file should be *\0010 \workshop\0010_workshop_00 01.txt
IMPORTANT NOTE * represents watever the folder path
one more example fir 0030
0030 \components
\notes
\notes
\workshop\0030_workshop_00 01.txt
0010.txt should be copied to 0030 \workshop\ and should be renamed 0030_workshop_0001.txt
the complete path of the file should be *\0030 workshop\0030_workshop_000 1.txt
"components" "notes" "version" Folders are just emply folders which would be used latter on
0010.txt
001.txt
asd0.txt
0030.txt
0040.txt
0050.txt
vbs script should create folder structure like this for for every individual file
for 0010.txt
0010 \components
\notes
\version
\workshop\0010_workshop_00
0010.txt should be copied to 0010 \workshop\ and should be renamed 0010_workshop_0001.txt
the complete path of the file should be *\0010 \workshop\0010_workshop_00
IMPORTANT NOTE * represents watever the folder path
one more example fir 0030
0030 \components
\notes
\notes
\workshop\0030_workshop_00
0010.txt should be copied to 0030 \workshop\ and should be renamed 0030_workshop_0001.txt
the complete path of the file should be *\0030 workshop\0030_workshop_000
"components" "notes" "version" Folders are just emply folders which would be used latter on
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
any thing is acceptable :)
ASKER
Thank you....very much
Very welcome, glad to help, thanks.
~bp
~bp
ASKER
+---001
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 001_workshop_0001.txt
001_workshop_0002.txt
001_workshop_0003.txt
001_workshop_0004.txt
001_workshop_0005.txt
¦
+---0010
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 0010_workshop_0001.txt
¦ 0010_workshop_0002.txt
¦ 0010_workshop_0003.txt
0010_workshop_0004.txt
0010_workshop_0005.txt
0010_workshop_0006.txt
0010_workshop_0007.txt
0010_workshop_0008.txt
0010_workshop_0009.txt
0010_workshop_0010.txt
0010_workshop_0011.txt
¦
+---0030
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 0030_workshop_0001.txt
0030_workshop_0002.txt
NOW I need a bat file That can copy the last version of the 001.txt(i.e 001_workshop_0005.txt) to its main folder (i.e 001 folder ) and name it has 001_Final.txt
The Result should be
+---001
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 001_workshop_0001.txt
001_workshop_0002.txt
001_workshop_0003.txt
001_workshop_0004.txt
001_workshop_0005.txt
001_Final.txt (this file should be a copy of 001_workshop_0005.txt )
¦
+---0010
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 0010_workshop_0001.txt
¦ 0010_workshop_0002.txt
¦ 0010_workshop_0003.txt
0010_workshop_0004.txt
0010_workshop_0005.txt
0010_workshop_0006.txt
0010_workshop_0007.txt
0010_workshop_0008.txt
0010_workshop_0009.txt
0010_workshop_0010.txt
0010_workshop_0011.txt
0010_Final.txt this file should be a copy of 0010_workshop_0011.txt )
¦
+---0030
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 0030_workshop_0001.txt
0030_workshop_0002.txt
0030_Final.txt this file should be a copy of 0030_workshop_0002.txt )
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 001_workshop_0001.txt
001_workshop_0002.txt
001_workshop_0003.txt
001_workshop_0004.txt
001_workshop_0005.txt
¦
+---0010
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 0010_workshop_0001.txt
¦ 0010_workshop_0002.txt
¦ 0010_workshop_0003.txt
0010_workshop_0004.txt
0010_workshop_0005.txt
0010_workshop_0006.txt
0010_workshop_0007.txt
0010_workshop_0008.txt
0010_workshop_0009.txt
0010_workshop_0010.txt
0010_workshop_0011.txt
¦
+---0030
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 0030_workshop_0001.txt
0030_workshop_0002.txt
NOW I need a bat file That can copy the last version of the 001.txt(i.e 001_workshop_0005.txt) to its main folder (i.e 001 folder ) and name it has 001_Final.txt
The Result should be
+---001
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 001_workshop_0001.txt
001_workshop_0002.txt
001_workshop_0003.txt
001_workshop_0004.txt
001_workshop_0005.txt
001_Final.txt (this file should be a copy of 001_workshop_0005.txt )
¦
+---0010
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 0010_workshop_0001.txt
¦ 0010_workshop_0002.txt
¦ 0010_workshop_0003.txt
0010_workshop_0004.txt
0010_workshop_0005.txt
0010_workshop_0006.txt
0010_workshop_0007.txt
0010_workshop_0008.txt
0010_workshop_0009.txt
0010_workshop_0010.txt
0010_workshop_0011.txt
0010_Final.txt this file should be a copy of 0010_workshop_0011.txt )
¦
+---0030
¦ +---components
¦ +---notes
¦ +---version
¦ +---workshop
¦ 0030_workshop_0001.txt
0030_workshop_0002.txt
0030_Final.txt this file should be a copy of 0030_workshop_0002.txt )
Okay, that's doable, just a minute...
~bp
~bp
I think this should do what you asked for.
@echo off
setlocal EnableDelayedExpansion
set BaseDir=c:\Temp\EE26850102
for /D %%A in ("%BaseDir%\*") do (
if exist "%%A\workshop\" (
for /F "tokens=*" %%B in ('dir /b /a-d /on "%%A\workshop\*.txt"') do set LastFile=%%B
copy "%%A\workshop\!LastFile!" "%%A\workshop\%%~nA_Final.txt"
)
)
~bp
ASKER
Worked like a charm Thank you very much.. :)
Welcome.
~bp
~bp
~bp