DOS script to pass sub-folder name dynamically

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Sanders_2503
Posts: 3
Joined: 05 Oct 2011 11:33

DOS script to pass sub-folder name dynamically

#1 Post by Sanders_2503 » 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 -


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.

Sanders_2503
Posts: 3
Joined: 05 Oct 2011 11:33

Re: DOS script to pass sub-folder name dynamically

#2 Post by Sanders_2503 » 11 Oct 2011 16:16

I figured it out. Instead of passing the -o parameter if we just mention C:\7za.exe e C:\Downloads\Prevalidation*.zip then it will extract the files to the folder where I am running the batch script from. Then I am moving these *.psa files to my desired location and running my dir and del commands so on.

Post Reply