[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Sat, 27 Dec 2008 11:19:20 +0000, Simon Robert <simon.robert@xxxxxxxxxxxxx> wrote: >actually the files are windows media, wmv if I remember, but I can do >that change. And no, they're not in the same directory. > >How would one go about executing this form an ftp session? > >Your help really is appreciated > >Simon take the attached file (if the list allows attachments) edit the following lines to reflect your ftp server - my $ftpserver = "192.168.1.18"; my $user = "ftpuser"; my $password = "ftppassword"; change $newname =~ s/\-1\.jpg/\.jpg/; to $newname =~ s/\-1\.wmv/\.wmv/; near the end of the script to handle wmv files run it from a shell prompt by typing - perl ftp-rename2.pl (I have tested it on both my Eee and my XP box(ActiveState Perl)) it should print a full directory tree from the ftp server >> / -->> testdir ---- test1.jpg ---- test2.jpg ---- test4-1.txt ---- test5-2.jpg ---->> dir1 ------ test1-1.jpg ------ test2-1.jpg ------ test5-2.jpg ---->> dir2 ---- test1-1.jpg ---- test2-1.jpg ---->> dir 3 ------ test 4.txt ------ test 5-1.jpg ------ Test 6-1.jpg edit the following if you know which sub-tree you want my $startdirectory = "/"; edit the following if your directory tree is deeper or wider my $max_depth = 10; my $max_cd = 100; then edit my $action = "none"; to my $action = "rename"; and run the script again. it should print out the renames it would do (but no actually do anything) >> / -->> testdir ---->> dir1 ------ test1-1.jpg => test1.jpg ------ test2-1.jpg => test2.jpg ---->> dir2 ---- test1-1.jpg => test1.jpg ---- test2-1.jpg => test2.jpg ---->> dir 3 ------ test 5-1.jpg => test 5.jpg ------ Test 6-1.jpg => Test 6.jpg if you are *totally* happy with what it wants to do, and take full responsablility for the results, edit my $simulate = "true"; to my $simulate = "false"; and it will actually change the files (I hope) There is no error checking for failed directory changes or failed renames :-/ OB ink-jet-printers: try Googleing for MJL6151L - very nice bit of kit, print heads a bit expensive when they wear out. hope this helps Dave -- http://www.morgad.co.uk/index.html DP: http://www.pgdp.net NTP: http://www.pool.ntp.org L&B: http://www.lynton-rail.co.uk
Attachment:
ftp-rename2.pl
Description: Binary data
-- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html