Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

another script question



gboyce wrote:
> matt nicholson wrote:
>> many of them are too long for the xbox filesystem.
>> theres alot of them and the are all spread out across
>> my /path/artist/album/track style directories.
>> 
>> does anyone know of a quick script or something to just walk through a
>> directory recursively, and remove any "trailing" characters off the end
>> of the files (not the directories?)
> 
> According to the documentation I've found, the fatx filesystem used by 
> the xbox supports filenames of 42 characters...

Assuming files with an .mp3 extension, and a length limit of 42 
characters (including the extension), this should do it:

find . -name "*.mp3" | rename -v \
's|(.*/)(.*)(\.mp3)|$1 . substr($2,0,38) . $3|e'


providing you find yourself a copy of the previously mentioned 'rename' 
Perl script.

If you can't find the script or don't have Perl on the box, you might 
want to investigate 'awk'. It's the next best tool for this kind of 
string manipulation. You could pipe the output of 'find' to it.

'find' itself supports a printf action in which you can specify the 
formatting of file names and paths, including their widths, but like the 
C printf() it doesn't truncate strings that exceed the specified width, 
it only pads the fields with spaces.

  -Tom

-- 
Tom Metro
Venture Logic, Newton, MA, USA
"Enterprise solutions through open source."
Professional Profile: http://tmetro.venturelogic.com/




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org