1
votes

The problem I have relates to the file name being truncated on the first space in the file name.

7z a -t7z "D:\IDRIVE\New backups\Program\full\6\File.7z" "D:\IDRIVE\New backups\Program\full\4\*.*" -mx9

The above is the batch code i use ( Actually i use date instead of file,but i want to change to original name)

File1.bak becomes file.7z

File2.bak becomes file.7z

And if am having two files in a folder, the 7zip will compress

File1 and File2 and it becomes a single file named file.7z

I want it to be compressed separately as follows

File1 becomes File1.7z

File2 becomes Files2.7z

Please give me your valuable suggestions

But it's zipping file and also changing it's name to the date and time which it's getting zipped (It was my only option at that time). Actually i don't want to change it's original name.

And with this code the two files in a folder are compressed to a single file. I want them to be compressed separately

I want to know how to make it possible.. I am not very good in batch file programming

1

1 Answers

1
votes

You can't achieve the intended using 7z.exe, because the way it works on cmdline is same as the way zip and tar works, you need to provide the archive names followed by the filename you want to zip. Its nothing like it works on gui.

But you can put following line in a batch file

7z.exe a -tzip "%~n.zip" "%1"

And call the batch file like

batch_file filename.bak

It will produce filename.zip

If you have to do it for many files then you can modify your batch file as follows

FOR %%I IN (*.bak) DO (7z a -tzip "%%~nI.zip" "%%I")

For this you have to go in a floder where bak files are, and run this, it will create .zip files I hope one can try other required modifications around this solution