|
Answer» Hello All,
I am a rookie at DOS and looking for some HELP on a batch file. I have a bunch of .zip files (in same folder) that I am unzipping with PKUNZIP. I'd like to unzip each file and then rename. Each zip file contains one CSV file but the name of that CSV file is random and long. The folder only contains the zip files when I start run the batch. The SAMPLE code below worked in PART but I got messages about duplicate files and then it started renaming the first files I unzipped. I'm pretty sure this is not how you set up a loop. Your help and guidance is appreciated. Ben.
pkunzip 2001.zip rename ??.csv 2001.csv pkunzip 2002.zip rename ??.csv 2002.csv pkunzip 2003.zip rename ??.csv 2003.csv pkunzip 2004.zip rename ??.csv 2004.csvAs I rememer it, pkunzip -v will tell you the content of the zip, you could capture this and then know what to rename from after extractingThanks for the info. That is beyond my KNOWLEDGE right now. When I unzip, the file name does get truncated and that name will always be random numbers. I know I NEED to do FOR... to unzip and rename a .CSV file using a wildcard but b/c I don't know the file name. Try something like
Unzipper.Bat Code: [Select]for /f "delims=" %%A in ( 'pkunzip -v %1' ) do set ZippedName=%%A pkunzip %1 Ren %ZippedName% %~n1.csv Usage Unzipper 2001.zip
Ive not tested it as I dont have pkzip / unzipThank you gpl and ffree. I tried both. I was able to get ffree's codes to work. The move gave me another idea so I tried a variation on my original idea. I had to create another folder to move the unzipped and renamed files to but it worked. However, I have to do this from 1990 to 2010. Not a big deal...just copy and paste in Notepad, but if someone can help me turn the code below into a loop, I would appreciate it and learn from it. Thank you all!
pkunzip 1990.zip rename *.csv 1990.csv move *.csv csvfolder pkunzip 1991.zip rename *.csv 1991.csv move *.csv csvfolder
|