1
vote
3answers
50 views

rename hundreds of file by removing last few characters

I have hundreds of file andI want to remove last 7 characters from the filename but keeping its extension. Old name: abc_xyz12_4567.txt abcde_xyz12_4567.txt New name: abc_xyz.txt abcde_xyz.txt ...
1
vote
2answers
114 views

Rename a file dynamically containing spaces [duplicate]

I want to rename a file dynamically based on data which contains spaces Name="Abc DEF" Name1="GHI JKL" mv /sample/pdf/noriginalName.pdf /sample/outputPdf/${NAME}${Name1}".pdf" But it gives me an ...
4
votes
1answer
325 views

replace all dots in filenames with underscore

I have a directory with some subdirectories with filenames and directorynames that contain some dots: $ ls -R .: dir file.with.dots ./dir: subdir.with.dots ./dir/subdir.with.dots: other.file I ...
21
votes
3answers
2k views

How to rename file to .. (dot dot)?

Apparently you can rename file to .... If I were insane, how would I rename file to .. or .? Is such a filename even allowed? Backslash doesn't seem to disable dot's special meaning: $ mv test \. ...
1
vote
2answers
146 views

How would I change file permissions if the file name has a space in it in linux [duplicate]

I would like to know how would I rename and change file permissions of a file that contains a space in the name on Linux. Example The name of my file is: my file I have tried mv my%20file my_file ...
6
votes
5answers
337 views

Renaming files with its path name

I have a .bdf file inside subfolders. All the .bdf have the same name: Loads.bdf Example: /home/user/folderxx/folderxxx/Load.bdf /home/user/folderxx/folderxxx/Load.bdf I need to find (and copy to ...
2
votes
2answers
135 views

Shell Scripting: how to use part of the file path as the file name?

I have a group of directories, each containing exactly 1 jpeg image, like so- /psds/folder1/image.jpg /psds/someotherfolder/picture.jpg /psds/yetanotherfolder/thumbnail.jpg What is the appropriate ...
3
votes
3answers
122 views

Change the name of a file that contains spaces in the name

I don't know why but when I go to change this file name with mv command it comes up with the error stating not a directory. -bash-4.1# mv {{ THEME SANITIZED }}.hacks.css myomega.hacks.css
1
vote
2answers
239 views

How to batch clean filenames containing invalid characters

I have a larger directory with files whose filenames contain special characters such as line breaks. The origin of these characters is seemingly that I copied and pasted text from within pdf files ...
0
votes
1answer
224 views

Rename multiple files removing last characters and renumbering

I have a photo directory with hundreds of files named in the format: 2013-08-02 19.21.27.jpg I wish to keep the first 10 characters (date) and append "-001", etc. being consecutive for each date. ...
1
vote
1answer
310 views

rename multiple files recursively and remove multiple characters such as ? : or newline from names

I have seen a few similar questions, but nothing that shows how to remove any of a set of special characters from all file names recursively. I want to keep uppercase and lowercase letters, numbers ...
2
votes
1answer
218 views

Merging folders with practically the same name but different casing

When digging around in the advanced settings in Dropbox I lost a folder. I only discovered this about a month later. I managed to get this folder back from Dropbox however the file structure of the ...
7
votes
3answers
569 views

Generate new name for moved file to prevent overwriting?

How can I generate a new name for a file if there's an existing file With that same name? In a Desktop environment a new name is generated my appending a number to the end of the file name, but how ...
1
vote
1answer
292 views

Trouble with mv and adding the date

I want to be able to move $oldfile to my backup folder and add the date to the file name. So I tried this... mv $oldfile /home/u0146121/backupfiles/$oldfile_$(date +%F-%T) This just gives me this ...
1
vote
1answer
3k views

Adding a time stamp when moving a file in bash [duplicate]

#!/bin/bash while read server <&3; do #read server names into the while loop if [[ ! $server =~ [^[:space:]] ]] ; then #empty line exception continue fi echo "Connecting to - ...
2
votes
2answers
210 views

how to copy and rename files with “:” and incrementing number in the filename

I need to copy and rename (and then edit) a group of files in the /etc/sysconfig/network-scripts folder. The files are ifcfg-eth1:* I have ifcfg-eth1 through ifcfg-eth1:121 but need to extend with ...
2
votes
3answers
971 views

Need to trim the names of file names

I have files in UNIX directory which have a unique number starting with, i have to remove the unique id followed by '-' from the file name and need to have regular file. Any help is appreciated. ...
2
votes
3answers
1k views

Replace filename with parent folder name

I have a bunch of files each in their own subdirectory. I need to write a script to rename each file to have the same name as its directory: For example, given: ./1111/1234.pdf ./2222/2345.pdf ...
2
votes
5answers
236 views

move a directory with a single character (back quote) as its name [duplicate]

How can I move a directory whose name is just a space? ls -lah drwx------ 4 user1 user1 8.0K Mar 13 14:16 . drwxr-xr-x 3 root root 60 Mar 13 13:48 .. drwx------ 18 user1 user1 4.0K Mar 13 11:18 ...
1
vote
2answers
173 views

How to “grab” matching files from a lookup file in bash?

I have a lookup file containing filenames. I also have a directory containing files, some of which have the names that correspond to some of the names in the directory. How can I: Move exact ...
3
votes
3answers
1k views

How do I remove carriage returns from directory names?

I created a file in Excel and ftp'd the file over to my Linux machine. In the file were a bunch of mkdir commands. Now all of the newly created directories have a carriage return at the end of them. ...
7
votes
3answers
4k views

adding text to filename before extension

I would like to add text to the end of filename but before the extension. Right now I am trying, for f in *.shp; do echo $f_poly; done the output is, Quercus_acutifolia.shp_poly ...
5
votes
5answers
3k views

Replace dots with underscores in filenames, leaving extension intact

I have a bash script which I'm trying to get to replace dots in filenames and replace them with underscores, leaving the extension intact (I'm on Centos 6 btw). As you can see from the output below, ...
0
votes
1answer
76 views

Find and use the path of a file?

I'm trying to find the path of a file and move it. When I try realpath, it is not useful. For example : I want to move the file All Hail the Generalist - Vikram Mansharamani - Harvard Business ...
9
votes
7answers
6k views

Bulk rename, change prefix

How can I bulk replace the prefix for many files? I have a lot of files like TestSRConnectionContext.h TestSRConnectionContext.m I would like to change all them to CLConnectionContext.h ...
0
votes
2answers
753 views

File extension case sensitivity on CentOS [duplicate]

Possible Duplicate: How to clean up file extensions? I'm using CentOS. There are >10M images in one of my folders, which are furthur grouped into subdirectories. The issue is that some of ...
3
votes
2answers
3k views

Remove prefixes from filenames

I have a bunch of files as follows: 04602635_b0294.DAT20120807164534 04602637_b0297.DAT20120807164713 04602638_b0296.DAT20120807164637 04602639_b0299.DAT20120807164819 ...
2
votes
1answer
405 views

Detect file-type with the help of magic-file and rename file-suffix accordingly

I have a folder (the iPhone Backup) with various files without a suffix. I want to run a batch process over these files, which detects each file's file-type (with the help of the magic-file database ...
3
votes
2answers
1k views

How do I find a bunch of files with a string in its filename (or body text) and then move all those files to a specific folder?

Say - what if I wanted to move every HTML file in several independent directories with the word "heavengames" in its filename (and as a second question, every HTML files with the word "heavengames" in ...
5
votes
4answers
787 views

For each subfolder, sort files by name and rename them to sequential padded numbers (regardless of extension)

I have the following directory structure: . ├── event-a │   ├── album-a │   │   ├── a.jpg │   │   └── x.png │   └── album-b │   ├── a.jpg │   ├── x.png │   └── y.gif └── event-b ├── ...
3
votes
3answers
560 views

Unique file name for different files

I'm working with graphic design. I've downloaded many files (EPS files, PSD files, etc) from various websites. Because it come from various websites, after downloaded from more than 10 different ...
3
votes
3answers
554 views

pull out a file named to ~

So I have downloaded a music album from aMule and it is located in the .aMule/Incoming directory. I tried to move it out with the following command: mv albumName.rar ~ This left me with a file ~ ...
2
votes
3answers
478 views

Rename a lot of files with all types of characters, with POSIX portability

Sometimes I need to rename all the files (the renaming convention follows later) in a directory where the filename is always in the form of 'filenamename.extension' (extension always exists and ...
3
votes
1answer
2k views

Rename All Files with a Certain Name

I'm trying to find certain files with the name "stringx" and replace the name (but not the extension) with "stringy". So basically for stringx.txt and stingx.cs, I'd want stringy.txt and stringy.cs. ...
9
votes
1answer
3k views

Why can't I have a folder and a file with the same name?

I've never had this problem before, but for some reason, I can't rename my folder to packages/. This is the structure: root - packages_old/ - packages When I try to rename the folder with ...
4
votes
3answers
3k views

How do I move some but not all files from one directory to another?

I need to move my files from one directory to other. But there is some issues. My file name pattern is like: apple.0, apple.<n>, n -> {0,1,2,3 ...~ } so mv apple.* will not work, because ...
0
votes
0answers
41 views

How to change ALL the postfixes of files in a single directory, single command [duplicate]

Possible Duplicate: How to clean up file extensions? have a directory full of files ending with .JPG I need to change them all to .jpg How?
17
votes
3answers
6k views

bulk rename (or correctly display) files with special characters

I have a bunch of directories and subdirectories that contain files with special characters, like this file: robbie@phil:~$ ls test�sktest.txt test?sktest.txt Find reveals an escape sequence: ...
8
votes
2answers
826 views

the slash (/) after a directory name on shell commands

I have a little question here. If I have two files, say filea and fileb, mv filea fileb would delete fileb rename filea to fileb Then if I have two directories, say dira and dirb, mv dira dirb ...