| Author |
Message |
motownmutt@ Grasshopper
Joined: 16 Sep 2004 Posts: 1
|
Posted: Thu Sep 16, 2004 12:42 am Post subject: make a script to make directories and copy files |
|
|
OK, I could easily have done this by hand two days ago, but I'm lazy and undisciplined. I'm backing up a bunch of files from different directories to a zip disk. All's I've managed/mangled together is the following pcode, I'd like to create a script file to do this for me. Here's what I have so far:
ls > newfileset v = read first line of newfile mmd z:/$v/ cd $v mcopy * z:/$v/ cd ..next line of newfile
more newfile bin c core cpp junk mail mbox newfile nsmail perl sed sysvars textrpg, (I think this is from waaaay back when? I've never even uncompressed it!)
I know I could make this in a minute using excel or vba, but well, you might've guessed this is a linux machine...
Does this warrant a code contest? Edited by: motownmutt at: 9/16/04 1:53 am
|
|
| Back to top |
|
 |
Cerulean Gokenin
Joined: 22 Oct 2004 Posts: 742 Location: London, England
|
Posted: Thu Sep 16, 2004 10:31 am Post subject: Re: make a script to make directories and copy files |
|
|
You want to back directorys up? How about
tar cxf /mnt/zip/backup.tar.gz /home/bob/folder
where 'folder' contains all the directories you want to back up? Or if you want a script which backs up everything in the file:
filestobackup.txt:
/home/paul/someimportantfolder/doc1.sxw /home/paul/Python/pyqt /home/paul/bin /home/paul/Blender
backup.py:
#!/usr/bin/pythonimport sys, osfilelines = list()f = file("filewithnames.txt", "r")pathtozip = "/mnt/zip/" # must end with a slashfor i in range(0, 100): s = f.readline() if not s: break s = s.strip() filelines.append(s)for filename in filelines: strippedFilename = os.path.basename(filename) command = "tar czf %s%s.tar.gz %s" % (pathtozip, strippedFilename, filename) print command if os.system(command) == 0: sys.stdout.write("Backed up %s successfully\n" % strippedFilename) else: sys.stderr.write("Error saving to disk\n") Edited by: Cerulean Wave at: 9/16/04 12:59 pm
|
|
| Back to top |
|
 |
ModusPonens if A then B, if B then C...
Joined: 22 Oct 2004 Posts: 368 Location: Baltimore
|
Posted: Thu Sep 16, 2004 6:28 pm Post subject: Re: make a script to make directories and copy files |
|
|
C#
class FileStuff{ static void Main() { //Make Directory System.IO.Directory.CreateDirectory("C:\\MyDirectory"); //Copy File System.IO.File.Copy("C:\\MyFile.txt", "C:\\MyDirectory\\MyFile.txt"); }}
|
|
| Back to top |
|
 |
Blankety Blank Man Ashigaru
Joined: 22 Oct 2004 Posts: 180
|
Posted: Fri Sep 17, 2004 4:53 pm Post subject: Re: make a script to make directories and copy files |
|
|
this is interesting... i've got a program on my computer (incomplete) designed to do the opposite: cause file system havoc! (though, for the most part only prank-style stuff: changing file/folder names, changing date modified, setting read only, but it can also delete stuff...) |
|
| Back to top |
|
 |
jorizel Guest
|
Posted: Mon Sep 05, 2005 5:51 am Post subject: im only asking??? |
|
|
hey,can i ask u something, plz dont ignore me coz i need it verymuch, this is my question how to make a copy C- system if ull answer my question im very thankful dude i need it for my my assignment coz im student of college computer science is cors, can u help??// just email me at jorizel_26@yahoo.com......... thanks!!!! takecare |
|
| Back to top |
|
 |
bdi Nobody
Joined: 21 Oct 2004 Posts: 1646 Location: Chicago
|
Posted: Mon Sep 05, 2005 10:08 am Post subject: |
|
|
If you have a C++ question, please start a new topic
in the C++ forum.
Thanks |
|
| Back to top |
|
 |
|