-1

1st off I am not very familiar with advanced programming. I have been following examples and trial and erroring things sometimes with not the right result.

I was up half the night trying to get this to work and was so close but not quite there. Basically I have a folder structure like this. JOB NUMBER/Photos In the photo folder there are 2 sub folders Hi-Res & Low-Res

I need a bat file in the Photos folder that will zip only the JPG in folder Low-Res then name the output zip file as JOB NUMBER - Photos.zip and save it to the photo folder.

On top of this once I had it working I need the zip files to be limited on their size. They must be not larger than 6mb so if they need splitting a simple 01 02 .... Can be prefixed to the zip name. I briefly saw that you could split the output based on size but didn't get that far!

Any help would be a life saver!!

UPDATE

My code so far.

for %%A in ("%%~dp0\..") do 7z a -tzip "%%~fA-Photos.zip" "Low-Res"

UPDATE @JonathonReinhart This gets the Low-res contents zipped & saved back into the Low-res folder which will be fine I just cant get the name on the zip file right. At the moment it saves as Photos-Photos.zip

for %%A in ("Low-res\Photos") do 7z a -tzip "%%~fA-Photos.zip" "Low-Res"

Legg1979
  • 31
  • 7
  • Show what you've tried. – Jonathon Reinhart May 21 '14 at 08:37
  • I will upload my code once I'm logged on I'm not on my PC yet using my phone so bear with me. – Legg1979 May 21 '14 at 08:38
  • Updated post showing what i have cobbled together – Legg1979 May 21 '14 at 09:09
  • Thanks Jonathon Reinhart. The edit you made creates a zip file called Photos-Photos.zip in the main JOB-Number folder. I need the filename to be JOB NUMBER - Photos.zip & stored in the Photos folder if possible. This was the problem i was having last night – Legg1979 May 21 '14 at 09:22
  • i have worked out how to get it to save to the Low-Res folder which will be fine but i just cant get the file name to be that of the JOB NUMBER main folder. for %%A in ("Low-res\-Photos") do 7z a -tzip "%%~fA-Photos.zip" "Low-Res" – Legg1979 May 21 '14 at 09:28
  • This is driving me mad it must be something simple. it has to be something to do with the %%~fA. But i cant work it out. Help!!!!!! – Legg1979 May 21 '14 at 10:47

1 Answers1

0

Test this in the photos folder.

@echo off
for %%z in ("%cd%") do (
   for %%a in ("%%~dpz%\.") do (
      7z a -tzip "%%~nxa-%%~nxz.zip" "Low-Res\*" 
   )
)
pause
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • Bingo, Works perfectly thank you! Much appreciated. Where can I learn all the tricks for CMD & BAT programming? is there any tutorial websites? I think im a bit out of depth here!! – Legg1979 May 21 '14 at 13:56
  • Here is a FAQ list http://www.netikka.net/tsneti/info/tscmd.php and get the `tscmd.zip` file mentioned near the top for more sample scripts. Reading batch forums and asking questions there is a good way of picking up tips, and changing then debugging scripts is a hands on way of learning. – foxidrive May 21 '14 at 14:45