Linux File Move/Rename help
#1
I've moved over to XBMCBuntu from XBMC on Windows 7.

I also use a Topfiled PVR to record TV.

In Windows I have a batch file that copies files from my Topfield (files are named 'blah_120709.rec') to my NAS and then strips out the _120709 from the filename and uses the resulting filename to create a directory and then move the file to that directory.

So 'blah_120709.rec' becomes 'blah.rec' in directory 'blah'.

I've got the copying from the Topfield to my NAS sorted. Can anyone help me with stripping out of the datestamp from the filename something like :-

Code:
for myfile in *.rec
mydsfile = remove datestamp and .rec from myfile
mkdir mydsfile
mv myfile mydsfile/mydsfile.rec
next

Zotac ZBOX HD-ND22
XBMCBuntu
Frodo / Confluence
2 x 3TB HDD
flirc
Harmony 885
Reply
#2
if its always like "name_12344" then:
mydsfile=${myfile//_*}

more general:
mydsfile=${myfile/[_0-9.rec]*}
Reply
#3
Thanks
Zotac ZBOX HD-ND22
XBMCBuntu
Frodo / Confluence
2 x 3TB HDD
flirc
Harmony 885
Reply

Logout Mark Read Team Forum Stats Members Help
Linux File Move/Rename help0