Ubuntu :: Script For Renaming Files Giving Them The Name Of The Folder They're In?
Feb 2, 2010
I have a folder where all of my movies are placed. Each movie lies in its own folder. I want to write a script which renames all the movie files and gives them the name of the folder they are in.For example I want this file:/home/tryfon/movies/Black Irish [2007]/black.irish.dvdrip.avi to be renamed to /home/tryfon/movies/Black Irish [2007]/Black Irish [2007].aviOne issue is that the video files are of several file types (mostly avi, divx and mkv).Another issue is that some movies consist of two parts, so if a second avi file is found I would like the two (or more) files to be named like: "Black Irish [2007] CD1" and "Black Irish [2007] CD2", or if this is not possible at least notify me of the folders that contain more than one video fil
View 2 Replies
ADVERTISEMENT
Mar 26, 2011
I'm trying to rename files recursively from a folder. I want to delete the & from every filename. i've searched the net and found the following script:
Code:
#!/bin/bash
dir=/whatever/directory
for file in `ls $dir` ; do
# ANYCASE TO UPPERCASE:
newname=`echo $file | tr '[a-z]' '[A-Z]'`
mv $dir/$file $dir/$newname
done
and changed it:
Code:
#!/bin/bash
dir=/home/test
for file in `find $dir -type f` ; do
#rename files containing &
newname=`echo $file` | tr '[&]' ''
mv $dir/$file $dir/$newname
done
But the for loop explodes the filename after each & sign, so i don't have a whole filename. if the file is named lorem & ipsum, the for loop will break it in 3 parts.
View 2 Replies
View Related
Feb 28, 2010
I created a little bash script for renaming files from a folderEvery time i hv to put that bash script file (rename.sh) in folder Is there any ways i will call (rename.sh) from terminal without moving rename.sh into any folder ?ne More Question : Whenever i run any .sh file automatically one .sh~ file created it is my programing mistake or is it exists ?
View 7 Replies
View Related
Mar 24, 2010
I have used avidemux to cut a mp4 file, choosing just a part of it, and I have discovered it automatically adds "avidemux" to the beginning of the name of the file, plus the author of the file and that I cannot edit the file to erase it. Note that I talk about "right click - properties", and that the file, as seen from home folder dont include the "avidemux" prefix, but if, for instance, I run the file with VLC, "avidemux" will appear, and that is annoying. how to delete that annoying avidemux prefix?
View 1 Replies
View Related
Jun 8, 2011
I have around 150+ folders in one directory. All contains some pdf files. Now i want to give some prefix no. to folder only not the files inside. How can i give the prefix to all my folders?Eg : Suppose i want no. 8562 then i want it like as follows
OLD FOLDER NEW FOLDER
ABC/ 8562-ABC/
AABC/ 8562-AABC/
View 2 Replies
View Related
Jun 17, 2011
Running kubuntu 11.04x64 w/ xrender and folder-view plasmoid:
I cannot view "open with" for directories on the desktop (but it is visible w/in dolphin file structure) and whenever I try to rename folders on the desktop it crashes and restarts (but the rename is successful and no open windows crash).
This glitch is reproducible under OpenGL and Xrender; had to switch over to xrender after a recent system update that seems to slow my computer to a crawl after a little time and kept it cause it seems much smoother and crisper.
Is there any way to fix these issues or is there an alternative to the folder-view plasmoid to view a folder content on the desktop that is more stable?
View 9 Replies
View Related
Feb 10, 2011
I have an FTP account that when they log in they go to /var/ftp/uploads according to etc/passwd.I want to temporarily stop the uploads from coming in, but don't want to change the password on that account. If I rename the uploads folder to something else, what will happen when they go to log in since the /var/ftp/uploads path is no longer valid?
View 6 Replies
View Related
May 20, 2011
All I want to do is rename the folder containing my VMs but when I do that it breaks the VMs. In the settings of the individual VMs under Storage, there is a location for the .vdi file which I think may be the culprit but I see no way to change it. So is there a way to easily just rename the folder without importing/exporting the entire VM?
View 5 Replies
View Related
Jul 25, 2011
I've got three server folder things but I'm wondering whether I could rename them to something a bit more neater.When I do try renaming one it comes up with this error.
View 4 Replies
View Related
Feb 10, 2011
I'm trying to rename ~11000 files. What has happened is I have files in the following format:
string1_100_string2_200_string3_300.log
now the numbers 200 and 300 are sometimes below 100 and the file looks like this:
string1_100_string2_99_string3_99.log
and I want to rename such files to be like this:
string1_100_string2_099_string3_099.log
I wrote a small matlab script but it seems to take forever so thought I'd try and do it bash and have got near to nowhere....
View 3 Replies
View Related
Jan 11, 2011
Whenever I download a file using Firefox or Google Chrome and it has a ' character on it's filename, the file is renamed and a is added before the '. It's really annoying and I'd like to know how can I solve this issue.
View 9 Replies
View Related
Mar 31, 2011
I've used Shotwell to give titles to a lot of photos, and now realise that I want to also rename those files using the title. I see that Shotwell saves the title into XMP IPTC structure, using this: dc:title[x]. how to batch rename a bunch of files using this data?
View 3 Replies
View Related
Feb 12, 2010
I have a folder with various subfolders of files. These files all have two extra characters on the end that I want to get rid of. How would I go about telling the terminal to go into X directory and every subdirectory of X directory, look for all files with the extra characters, remove them, and keep everything else the same?
View 3 Replies
View Related
Jan 23, 2011
I have a Netgear ReadyNAS NV in the basement, that I want to use to serve up video files over my network to a TV in the living room.
Now, I have a lot of files that HandBrake encoded and it gave the files an m4v suffix. Even when the files are in a codec that the TV can handle, it refuses to load them because of this suffix... so I want to rename them all.
This is fairly simple for files on a local filesystem. I can simply cd into the directory containing the files, and do something like the commands below.
Code:
$ for a in `ls`;
> do
> stem=`echo ${a} | cut -f1 -d"."` ;
> mv ${a} ${stem}.mpg ;
[Code]....
Although there are a few smb commands available (smbstatus, smbget, etc.), I've not found any commands like smbls or smbmv.
Are there any special commands or utilities around that can do the kind of thing I'm trying to do?
View 1 Replies
View Related
May 18, 2011
I managed to very stupidly (and avoidably) overwrite the hard drive that contained all my stuff--music, photos, home videos from the 80's that were painstakingly converted to digital movies, etc.After running Photorec and recovering much of the data to another disk, I'd like to be able to rename the music files using whatever exif data/tags are available.
View 6 Replies
View Related
Jun 21, 2011
I have many pdf files which contain "%" sign also in the name. I want to rename that all files by replacing "%" to "-" Its hierarchy of many files and folders. Is there any solution to do this at one time? OR any script for this?
View 7 Replies
View Related
Jun 8, 2010
What's the command for renaming files? I thought it was "mv"--I typed "info" and read
Quote:
* mv: (coreutils)mv invocation. Rename files. So, desiring to give a .JPG extension to a jpeg file that had no extension (because I dug it out of my Firefox cache), I typed
Quote:
mv '/home/josh/Desktop/Natalie pictures/DEC8FFA5d01' *.jpg
That didn't rename the file; it made the file disappear from its folder. What did I do wrong?
View 6 Replies
View Related
Apr 19, 2011
i have some files on my server that i can not rename or copy it seems file names are some how strange for linux (centos)the names are like this way :
Spirited.Away.2001.HDRip_-_(Film98-Net).mkv
Up.2009.BRrip_-_(Film98-Net).mkv
How.To.Train.Your.Dragon.2010.720p.Bluray_-_(Film98-Net).mkv
[code]...
View 6 Replies
View Related
May 22, 2010
how can I rename all files in a directory up to the first dot (there by leaving the file extension alone) to the same thing? Im trying to rename all my media files and associated files in a directory to (preferably) the name of the directory it self. if I have
Code:
A Clockwork Orange -
wzzyfg.cd1.avi
wzzyfg.cd2.avi
wzzyfg.nfo
ACO.fanart.jpg
orange.tbn
Id like to automatically mass rename them all to
Code:
A Clockwork Orange
A Clockwork Orange.cd1.avi
A Clockwork Orange.cd2.avi
A Clockwork Orange.nfo
A Clockwork Orange.fanart.jpg
A Clockwork Orange.tbn
I have rename on my server which I used to remove underscores from file names, but I dont know how I would use it to rename everything up to the first period. Bonus points for renaming stuff to the name of the parent folder!
View 5 Replies
View Related
Aug 4, 2011
I have hundreds of MTS and AVI files since 2000 and would like to rename them in the following manner based on the date created: DD-MMM-YYYY HH.MM.SS_X; where X begins at 1 and increments by 1 if there are dublicate date/time stamped videos.
Ex: 19-Nov-2002 08.12.30.avi, 19-Nov-2002 08:13:30_1 and 19-Nov-2002 08:13:30_2
Someone previously wrote the following script for me, and it works great for photos. It uses EXIV2 to get the image date created info. I have tried to understand the script, but am struggling. The video files I have can use the date modified since I have not modified them since I filmed them.
#!/usr/bin/env python
import os
import stat
import pyexiv2
import time
directory = '/home/david/Desktop/test'
[Code].....
View 1 Replies
View Related
Dec 11, 2010
I run a script which generated about 10k files in a directory. I just discovered that there is a bug in the script which causes some filenames to have a carriage return (presumably a '' character).
I want to run a sed command to remove the carriage return from the filenames.
Anyone knows which params to pass to sed to clean up the filenames in the manner described?
I am running on Linux (Ubuntu)
The character causing the filename to 'break up' accross multiple lines appear to be a CR (carriage return) instead of ' '. The filename is being diaplayed in thetitle of a text editor with %0D in the positions of where the file name breaks up. So I need to remove the CR chars from my filenames.
View 1 Replies
View Related
Apr 1, 2010
I'm trying to rename a lot of files getting rid of the space on the names. For that purpose I wrote this very simple bash script, but for some reason is not working.
Code:
for i in "$(ls)"
do
j=$(echo "$i" | sed 's/ /_/g')
mv "$i" "$j"
done But what I get in return for each line is just one long file name with all the file names concatenated. I've tried with echo -e "$i" as well with no results. This has to be something really simple that I'm missing but I just can't see it.
View 11 Replies
View Related
Jul 19, 2010
I have a bunch of files that I need to rename, ordinarily this is pretty easy task. The problem here is that the file names have Chinese / Japanese characters. ie [$$$$$$$$].SOMETHING BLAH BLAH.ext Where all the "$$$$" are insert Chinese characters. The problem is that sed or perl doesn't seem to handle the Chinese characters correctly so using a regular expression like this 's/^[*.]//' which would normally work doesn't. From what I have read so far I believe these characters are double encoded UTF-8 (not 100% sure) which could be the problem. So far I've tried numerous different regex's as well as playing around with convmv to see if I could convert the filenames to just single encoded characters but I've had no luck.
View 1 Replies
View Related
Sep 16, 2010
I have a TV/radio tuner and I installed the gkrellm-radio plugin. The plugin works fine, but, it only works with /dev/radio. I'm not sure if its safe to rename files so I just create a symlink of /dev/radio0 as /dev/radio.
It gets pretty annoying to me to have to create a symlink every time I start up my computer so I can listen to the radio. Is there a way to get linux to permanently name "/dev/radio0" as "/dev/radio"?
View 4 Replies
View Related
Apr 17, 2010
I often record music from the webradio with Streamtuner.How can I rename the mp3 files recorded in a way that numbers are added to the beginning of the filename representing the order in which the titles were played on the webradio station?I am looking for an automated solution like a renaming tool since there are usually hundreds of files in a directory. I used autorename / ARen for windows back in the day when I was still on XP. What I could do with the tool was:a) Sort the files by date of creationb) add an increasing number at the beginning of the filename based on the position in the sorted list.
View 3 Replies
View Related
Feb 12, 2011
I want to rename files in multiple subfolders with a prefix (e.g., rename "file.tif" with "prefix_file.tif") and not have to be in the subfolder.
code: for f in /path/to/*; do echo mv "$f" "PRE_$f"; done
gives you this: mv /path/to/file1 PRE_/path/to/file1
instead I want this: mv /path/to/file1 /path/to/PRE_file1
View 3 Replies
View Related
Mar 6, 2011
I have files whose names look like this:Sim1-2_40.36.chr20_sb.foo.indel.novoalign.samSim1-2_40.36.chr20_sb.foo.indel.bwa.samWhat I want to do is to replace all indel with snp in the namesyieldingSim1-2_40.36.chr20_sb.foo.snp.novoalign.samSim1-2_40.36.chr20_sb.foo.snp.bwa.samBut why this unix command doesn't work
View 4 Replies
View Related
Jul 20, 2011
Recently I installed Dropbox on a server to do file synchronization and it added " (Case Conflict 1)" to a whole bunch of my files! I realize now that it was caused by case insensitivity but I'm still left with hundreds of files that are in this renamed state. Is there a script in Linux that would allow me to recursively go through the directories and strip out this string?
i.e.
a (Case Conflict 1).jpg --> a.jpg
/myfolder/abc (Case Conflict 1).doc --> /myfolder/abc.doc
/myfolder/subfolder/mydoc (Case Conflict 1).pdf --> /myfolder/subfolder/mydoc.pdf
View 2 Replies
View Related
Apr 8, 2010
How can I copy multiple files, each with a slightly different name from the SOURCE in the same directory?
Example: '/home/junk' contains A.txt, B.txt
I want to copy /home/junk/A.txt to /home/junk/A1.txt and /home/junk/B.txt to /home/junk/B1.txt using a single command.
View 11 Replies
View Related
Feb 3, 2010
Basically I need to rename a bunch of .doc files using the for-structure and the mv command (w/ wildcards) in bash. I guess this would be a bit easier if I'd use the rename command, but since this is a school assignment of sorts I need to use for & mv. The .doc files are named "1filename.doc", "2filename.doc" etc. And I've got to rename them to "aaa_1filename.doc", "aaa_2filename.doc", "aaa_3filename.doc" and so on. Tried to dabble quite a bit with the for and mv commands, basically just got a bunch of errors. Every damn time. For 2 hours. The most common error was "mv: missing destination file operand after ..."
View 6 Replies
View Related