I have a load of video files that I have converted and the program that did it has renamed them with a ‘1’ at the end, e.g. Batman1.avi
What I now need to do, with a LOT of files is remove the ‘1’ and leave the rest of the name intact. I have had a go with Krusader/Krename but don’t know how to do it properly with either of them, if in fact it is possible with either of them, I have had a look through the instructions but don’t know if I have done it right?
How about something like this;
for i in `ls`
do
dst=`echo $i | sed -e "/1\./s//\./"`
echo "mv -v $i $dst"
done
Caveat; untested and as-is, will just print the rename commands rather then execute …
(remove the echo and quotes from the “mv” line to activate)
- Assumes regular filenames with only one “.” in them … (!)
I’m not that good on using terminal.
Do I enter each line in terminal?
If not, how do I do it?
How about a one-liner (assuming the ‘1.avi’ is constant and all files are in the same folder) :
rename -v 1.avi .avi *1.avi
or non verbose:
rename 1.avi .avi *1.avi
Just make sure to change into the directory first
I tried it and got;
pooky2483@pooky2483-ubuntu12:/media/Drive3/An Idiot Abroad/Season 01$ rename -v 1.avi .avi *1.avi
Bareword found where operator expected at (eval 1) line 1, near “1.avi”
(Missing operator before avi?)
syntax error at (eval 1) line 2, near "1.avi
"
pooky2483@pooky2483-ubuntu12:/media/Drive3/An Idiot Abroad/Season 01$
Hmm, that worked on Arch
It appears that Debian based distros implement the rename command differently, try this (untested not on Debian at the minute)
rename -v 's/1.avi/.avi/' *1.avi
Just to be pedantic, the Unix/Linux command for renaming files is “mv” rather than “rename” …
Just to be pedantic, the Unix/Linux command for renaming files is "mv" rather than "rename" ... :-)
OK, the mv version (slightly longer) would be:
for f in *1.avi; do mv "$f" "${f/1.avi/.avi}"; done
Sure, you can always condense stuff, indeed there was a Perl ‘fad’ (many years ago now) of seeing how much you could get on one line, or indeed writing an entire (complex) program on one line … this sort of died out once people figured out that the next day they couldn’t make head nor tail of what they’d just written …
I was just pointing out that ‘rename’ isn’t a standard command, rather it’s a Perl script - Perl being the root of all evil in the scripting world and to be avoided at any cost …
I must admit I’d not seen the inline pattern matching before (see my more verbose ‘sed’ example above) , is this standard in all shells, or specific to bash and / or dash ???
Sent from my rk30sdk using Tapatalk HD
'Fraid nothing happened!
'Fraid nothing happened!
That command is not verbose (would not print to screen)
Did you cd into the directory?
Also did you try the rename command?
Sorry, it DID work.
I had to COMPLETELY close ‘window’ - nautilus ‘Drive3/An_Idiot_Abroad/Season_01/filename.avi’
when I just collapsed the window and re-opened it, there was no change visible?
Any idea why that is?
Any idea why that is?
Nautilus (and other file managers) scan for changes in set intervals, not constantly, and eating up resources in the process.
All you had to do is click Refresh
I’m seriously going to have to get a book on terminal commands
I thought you had a Motorola Xoom ?
Are you going to do a mini review of the rk30sdk ?
Xoom is elsewhere … This is a new Android box …
Ok, this is what my device looks like, Android 4.1, dual core processor (very quick) cost is £39.99, you can just see it sticking out of the left side of the telly … (plugs directly into the HDMI port).
[smg id=1565]
Summary review:
- Seems to address most / all of the problems listed in the older model (see previous review)
- Quick, more processor cores, more memory, can’t stress the speed difference enough
- Seems to have DRM options built in (newer Android)
- BBC Player, and ITV Player now work well
- Even Cheaper @ £39.99
Only issues I’ve had this far are (a) no power supplied, needs a USB power supply. Initially I plugged it into the Telly’s USB port, which worked but caused reboots every minute, but using the old Android media player’s USB port solved that (!) , now using the USB transformer from a Nexus 4, that works fine. And (b) there’s only one USB port on this one, so you’ll need a combined wireless mouse + keyboard, separate won’t do you any good (!)
I know it’s cheaper than the other model, and I know the other model looks “slicker” and comes with two USB ports and comes with a remote control (no remote with this one!) but it performs maybe 4x better than the other model - so if you’re going for one of these, make sure you get the mk809!
Ahh … I thought you’d got one of these@
http://www.bigboxsave.com/rk30sdk-7-inch-ips-1024-600-pixels-touch-screen-android-4-0-4-dual-core-1-6ghz-16gb-bluetooth-hdmi-dual-2-0mp-camera-tablet-pc.html