1

I've already learn how to batch compress my files as-is with 7zip but I have something more complex need on this issue. Maybe I can explain my needs with this scenario;

I have a backup folder of my drawings and model files and they are in their client's subfolders, so its folders-tree something like this:


Folder01\file1.abc, file2.abc, file3.def, file4.def

or

Folder02\Folder03\file1.abc, file2.def


...and so on.

Is there a way to compress each *.abc file beside of original file and in its original place or similar solution for this kind a situation?

  • I don't know why you want to compress each file separately in its original location. 7-zip can store relative paths as well, so it'll be much more efficient to create one single archive in the parent folder with all the *.abc files stored along with their paths. – Karan Jun 5 '15 at 10:24
  • @Karan Well, you are right but in my case, they are stored in a nas unit, several colleage of mine reach them and mail them. This way, they only need to find and copy as is. Also folders are contains renders of building models and this makes things easier for them to identify the job/client. This is maybe more complex solution but in the long run it has its advantages – Cagatay Jun 5 '15 at 10:46
0

Try saving the following batch file in the root of your folders and run it there:

@echo off
for /R %%f in (*.abc) do (7za a %%~pf%%~nf.zip %%f)

This tells the batch file to recursively (/R) look through the folders for any (*.abc) file and run the 7za command.

%%~pf is the current path in the loop, %%~nf is the file name without extension, which is why I then tack on .zip. %%f is the full path to the current *.abc in the loop.

  • As a rookie, I couldn't return to my original post or comment to Josh R's post either and sorry if This's against to rules. @echo off for /R %%f in (*.abc) do ("C:\Program Files\7-Zip\7z.exe" a -tzip -mx9 "%%~pf%%~nf.zip" "%%f") I changed his lines to this way because some of my files contains another dot or space in their names and Josh R's suggestion returns with issues on them. Of course, his respond solve my issue and I would like to this question marked as answered and thanks for the info Josh R – Cagatay Jun 4 '15 at 15:19
  • 1
    Are you @Cagatay? If so, you can flag this post and one of the mods should be able to merge your accounts. – dsolimano Jun 4 '15 at 17:53
  • Yes, I've send the question as unregistered and when the account activation I guess I've made some mistakes some point of the process. – Cagatay Jun 5 '15 at 6:35
  • 1
    You can use the "contact us" link at the bottom to get accounts merged. Its something a dev has to do – Journeyman Geek Jun 5 '15 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.