0

Is there a way to rename my .zip files as the name of their contents?

For example, my .zip files are named things like 5699302394mpnasth.zip but the inside of them is associated directly with a shapefile (for qgis) as something like 120345 and these are the file names that I know. Is there anyway I can rename the .zip?

I tried ren c:\location\*.zip "c:\location\(directory of the inside of the zip)\"zip

But I didn't have any luck. I am brand new to this and just messing around.

phuclv
  • 37,963
  • 15
  • 156
  • 475
  • take a look here and list option of zipjs - https://stackoverflow.com/questions/28043589/how-can-i-compress-zip-and-uncompress-unzip-files-and-folders-with-bat – npocmaka Jun 20 '17 at 05:47

1 Answers1

0

You'll need zipjs.bat in the same directory

set "zip_file=C:\567.zip"

for /f "tokens=* delims=" %%a in ('zipjs.bat list -source "%zip_file%" -flat no^|find /i ".qgis"') do set "new_name=%%a"

ren "%zip_file%" "%new_name%.zip"

if you want to iterate more files you'll need to wrap this in one more for loop and delayed expansion

npocmaka
  • 55,367
  • 18
  • 148
  • 187
  • Thanks! I have it set up as a folder using the program Directory Monitor. Currently the file just unzips things, but I am going to try adding this script so it will both unzip and rename. I used this tutorial to set up my folder http://www.guidingtech.com/24662/automatically-extract-zip-files/ – ajspaghetti Jun 20 '17 at 13:42