DOS script to pass sub-folder name dynamically
Posted: 11 Oct 2011 12:24
I am using 7zip in my dos script to extract a zip file but then 7-zip creates a sub folder (with the same name as that of the zip file) to store the files extracted. Eventually, I want to scan the folder with extracted files in it and create a file with the file name and timestamps of the files created.
This is what is happening -
The file named list_of_psa_files.txt now shows only one file which is the original zip file, whereas all my extracted files are inside the sub-folder created by 7-zip.
1. Can't I have 7-zip extract the files to the same folder where the zip file is located?
2. In case the answer to the above question is a No, how can I pass the sub-folder name in my dos script at run time (I dont know whats the sub-folder name 7-zip is going to create, since it is based on the original zip file name, and that changes) so that I can scan through the folder and list down the file names of all the files extracted there along with their timestamps.
Thanks. Much appreciate your help.
Sanders.
This is what is happening -
Code: Select all
:MAIN
C:\7za.exe e C:\Downloads\Prevalidation\*.zip -oC:\Downloads\Prevalidation\*.psa
dir "C:\Downloads\Prevalidation\" > C:\Downloads\list_of_psa_files.txt
del C:\Downloads\list_of_file_tsrcvd.csv
FOR /F "tokens=1,2,3,5 skip=7" %%A in (C:\Downloads\list_of_psa_files.txt) DO ( @echo %%A %%B %%C %%D >>
C:\Downloads\list_of_file_tsrcvd.csv )
exit
The file named list_of_psa_files.txt now shows only one file which is the original zip file, whereas all my extracted files are inside the sub-folder created by 7-zip.
1. Can't I have 7-zip extract the files to the same folder where the zip file is located?
2. In case the answer to the above question is a No, how can I pass the sub-folder name in my dos script at run time (I dont know whats the sub-folder name 7-zip is going to create, since it is based on the original zip file name, and that changes) so that I can scan through the folder and list down the file names of all the files extracted there along with their timestamps.
Thanks. Much appreciate your help.
Sanders.