954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Zip files, move files, delete source (help me please)

Hello this is my first post on these forums.

For a little back ground into this, I recently installed a Linux server with the purpose of recording matches via a program called HLTV.

Now what I want to do is take the individual .dem files compress them one by one then move the compressed files to a different folder and delete the originals

I found a script that seemed to do the job but it doesn’t work and I can’t seem to debug it.

#!/bin/bash
HLDS= /hlds/cstrike/ #Working directory where demos are
REP=/hlds/cstrike/demos/ #copying directory
FORMAT=tar cvf
EXTENSION=tar
#FORMAT=zip #Compression using ZIP
#EXTENSION=zip #Associated extension
cd $HLDS
for files in `ls *.dem` do
     $FORMAT $files.$(date +%s).$EXTENSION $files
     echo "$files.$(date +%s).$EXTENSION compressed"
     mv $files.$(date +%s).$EXTENSION $REP
     echo "$files.$(date +%s).$EXTENSION moved"
     rm $files
     echo "$files deleted"
done;
echo "Demos are available in : $REP"


the source folder is /hlds/cstrike
destination folder is /hlds/cstrike/demos

file type is .dem


Thanks for any help.

MrRx7
Newbie Poster
3 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

without really looking hard at the code, these variable declarations will not work

this one the space can't be used

HLDS= /hlds/cstrike/

it needs to be

HLDS=/hlds/cstrike


also this will not work

FORMAT=tar cvf

I think you want to do this, you will need to place it in quotes

FORMAT="tar cvf"
shanenin
Posting Whiz in Training
217 posts since May 2005
Reputation Points: 10
Solved Threads: 17
 

Thanks for the help

MrRx7
Newbie Poster
3 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

your welcome :-)

is it doing what you want it to?

shanenin
Posting Whiz in Training
217 posts since May 2005
Reputation Points: 10
Solved Threads: 17
 

actually I was just about to give it a try

Im hoping so, would save me a bit of work

MrRx7
Newbie Poster
3 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You