LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 05-16-2004, 09:38 AM   #1
Awfki
LQ Newbie
 
Registered: Aug 2003
Posts: 2

Rep: Reputation: 0
Scripting question reg. filenames with spaces


I want to recurse through a directory structure under G:\MP3 and move all of the .wma files to G:\WMA with the same directory structure. In 4NT this "move /e /s G:\MP3\*.wma G:\WMA\". It would take "G:\MP3\B\Beatles\Abbey Road\The Beatles - Abbey Road - 01 - Come Together.wma" and move it to "G:\WMA\B\Beatles\Abbey Road \The Beatles - Abbey Road - 01 - Come Together.wma".

In cygwin/bash this does not appear to be easy at all, largely because of spaces in the filenames.

I could use 4NT but I only get into linux/perl every other month or so and am constantly having to relearn things. Switching to cygwin is an attempt to stay in *nixish environment enough to actually get good at it.

Anyway, I've tried some things with find and for and I've read about using null rather than whitespace as a delimiter. I've learned quite a bit but none of it has actually moved the files.

Any help would be appreciated.
--
Afwki

Last edited by Awfki; 05-16-2004 at 09:39 AM.
 
Old 05-16-2004, 12:09 PM   #2
wrongman
Member
 
Registered: May 2004
Location: Italy
Distribution: Debian Unstable 64bit
Posts: 99

Rep: Reputation: 15
i'm not sure i've understood, under linux, you want to move all the structure g:/MP3/* in G:/WMA/* ??
if it's like this... just

mv /path_of_mp3_dir/MP3 /path_you_want/WMA
 
Old 05-16-2004, 12:21 PM   #3
xlord
Member
 
Registered: Mar 2002
Posts: 75

Rep: Reputation: 15
why not just create a python program that will do it for your? or bash scripting is not that hard.. you can start here
 
Old 05-16-2004, 09:01 PM   #4
Awfki
LQ Newbie
 
Registered: Aug 2003
Posts: 2

Original Poster
Rep: Reputation: 0
More info

For wrongman:
I want to duplicate the directory structure. The orginal dir (G:\MP3) has MP3s and WMAs. I want to move just the WMAs into a duplicate structure under G:\WMA.

For xlord:
I'm trying to do it in bash but don't know how to because:

A) I only want to move *.wma
B) The filenames contain spaces.

I attempted something like for x in `find . -name "*.wma"; do echo $x; done` and discovered that for takes the space as a delimter. I've tried some things involving grep -Z and find -Z and xargs but haven't got anything will correctly print all the file names so I'm certainly not going to trust it to move anything.

I'll probably end up doing this in perl but wanted to attempt it in bash.


Last edited by Awfki; 05-16-2004 at 09:06 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
filenames with spaces antony.booth Programming 5 11-01-2005 05:49 AM
ls and filenames with spaces rose_bud4201 Programming 10 07-01-2005 09:28 AM
bash scripting: filenames with spaces joanq Programming 2 05-24-2005 01:50 PM
BASH scripting problem, spaces in filenames / using basename textures Programming 24 11-16-2003 02:41 AM
spaces in filenames ebone Linux - General 2 11-12-2001 12:56 PM


All times are GMT -5. The time now is 04:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration