1.

Solve : DIR compression?

Answer»

I have written a batch script to backup my usb drive and i am now wanting to know if there is a way that i can get it to compress that backup folder throught the command line.
This is the backup part of the script

Code: [Select]ECHO.
echo ---------------------------------
echo Removable Device Automatic Backup
echo ---------------------------------
echo Backing Up Data
DATE /t>>backup_log.txt
time /t>>backup_log.txt
xcopy "*" "c:\removablebackup\" /e /y /r /h /c
echo End Back Up>>backup_log.txt
echo ------------------------------------------------------>>backup_log.txt
move "backup_log.txt" "log files/"
echo Backup Complete!
pause
exit
Can ANYONE help.

Thank you for your help!!You want to compress as in the Windows NTFS compression?  Or something LIKE ZIP compression?  ASSUMING you want NTFS compression, you could do something like:

ECHO.
echo ---------------------------------
echo Removable Device Automatic Backup
echo ---------------------------------
echo Backing Up Data
echo Backing Up Data on %date% at %time% >>backup_log.txt
xcopy "*" "c:\removablebackup\" /e /y /r /h /c
echo Backup Complete, now compressing
compact /c /s:"c:\removablebackup\"
echo End Back Up at %time%>>backup_log.txt
echo ------------------------------------------------------>>backup_log.txt
move "backup_log.txt" "log files/"
pausesomething like a Zip compression would suit better for what i am wanting to do.Then that will depend on the program you use to zip up your backup.  In fact if that is what you want to do, then it MAKES more sense to skip the copy, and just go straight to the compression.  Assuming you are using the registered version of WinZip (with the command line extensions) you can do something like:

Code: [Select]ECHO.
echo ---------------------------------
echo Removable Device Automatic Backup
echo ---------------------------------
echo Backing Up Data
echo Backing Up Data on %date% at %time% >>backup_log.txt
wzzip -rp c:\removablebackup\backup.zip *
echo End Back Up at %time%>>backup_log.txt
echo ------------------------------------------------------>>backup_log.txt
move "backup_log.txt" "log files/"
pause
The 1 line that does the backup is the:
wzzip -rp c:\removablebackup\backup.zip *

That line can be replaced with whatever program you want to use for your compression.  If you use TAR, it would be
tar -czvpf c:\removablebackup\backup.tgz *

There are dozens of other programs to do the compression, but the syntax for each will be specific to that program.



Discussion

No Comment Found