User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 402,749 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,520 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 5016 | Replies: 4
Reply
Join Date: Aug 2005
Posts: 3
Reputation: MrRx7 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MrRx7 MrRx7 is offline Offline
Newbie Poster

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

  #1  
Aug 30th, 2005
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
shanenin shanenin is offline Offline
Posting Whiz in Training

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

  #2  
Sep 11th, 2005
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"
In a perfect world exceptions would not be needed.
Reply With Quote  
Join Date: Aug 2005
Posts: 3
Reputation: MrRx7 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MrRx7 MrRx7 is offline Offline
Newbie Poster

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

  #3  
Sep 12th, 2005
Thanks for the help
Reply With Quote  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
shanenin shanenin is offline Offline
Posting Whiz in Training

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

  #4  
Sep 12th, 2005
your welcome :-)

is it doing what you want it to?
In a perfect world exceptions would not be needed.
Reply With Quote  
Join Date: Aug 2005
Posts: 3
Reputation: MrRx7 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MrRx7 MrRx7 is offline Offline
Newbie Poster

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

  #5  
Sep 12th, 2005
actually I was just about to give it a try

Im hoping so, would save me a bit of work
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 8:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC