The tag has no wiki summary.

learn more… | top users | synonyms

4
votes
4answers
931 views

What is the most efficient way to move a large number of files that reside in a single directory?

CentOS 5.x I apologize if this is a repeat question. I've seen a lot of similar questions (regarding deleting files) but not exactly the same scenario. I have a directory containing hundreds of ...
3
votes
3answers
2k views

How to rename multiple files in single command or script in Unix? [duplicate]

I have the below list of files aro_tty-mIF-45875564pmo_opt aro_tty-mIF-45875664pmo_opt aro_tty-mIF-45875964pmo_opt aro_tty-mIF-45875514pmo_opt aro_tty-mIF-45875524pmo_opt that I need to rename to ...
0
votes
2answers
139 views

How to change user name

I somehow changed my prompt (PS1) from [mpatil@localhost ~]$ to bash-4.1$. I also have changed my user mpatil's home directory from /home/mpatil to /home/algo. Now some applications are not working ...
0
votes
1answer
212 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
138 views

Copying wallpaper images into a single folder

In my ubuntu 12.04 set-up, there are lots of wallpaper images in the directory /usr/share/wallpapers. For example, one might be usr/share/wallpapers/Leafs_Labyrinth/contents/images/1600x1200.jpg ...
3
votes
4answers
131 views

Batch file rename with substitution lookup

Using bash, how I can batch rename a large number of files, where I need to construct a new name for each file, based on its existing name and a 'contextual map' - don't know what else to call it – of ...
2
votes
1answer
58 views

Linux shell - unexpected error

I'm new to the linux & command world. I have two directories, one called pasta (which contains 3 files) and another one called pasta2 (with nothing inside). I'm trying to move all 3 files from ...
1
vote
1answer
287 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 ...
3
votes
3answers
345 views

Adding prefixes/suffixes to file names without typing it all over again?

I would like to do something like the following $ tmp=name* $ mv $tmp new_$tmp $ ls new_* $ new_name-with-stuff-i-dont-want-to-type name-with-stuff-i-dont-want-to-type Setting the environment ...
2
votes
5answers
173 views

Rename files in directory

How to rename files in a directory such as the following file: PMC21375.pdf.txt, I need to be renamed to 21375.txt. i.e, I need to remove both PMC and pdf from each file name.
3
votes
2answers
38 views

Overriding amended time stamps

I need to make it so the files in current directory get amended with a timestamp. It works fine for the first time, but once I run it again it adds another timestamp to the file. I need a way to ...
5
votes
4answers
310 views

Allowing rename but not moving to other directory

Users can upload/delete/rename files via vsftp server and everything works well except they can also move files across directories. Is it possible to allow renaming of files but disallow moving them ...
1
vote
3answers
662 views

Batch file move to directory structure based on filename

I am writing a script to move files into directories based on the filename. Files have yyyyddmm-xxxxxxx.jpg name format. The desired directory structure is in the format 2013/01 Jan/31. I am unable ...
2
votes
2answers
124 views

Is there a --parents option for mv like for cp?

cp has a useful feature --parents that allows a file's directory structure to be copied to another directory: $ cp -v --parents source/directory/from target/ ‘source/directory/from’ -> ...
5
votes
2answers
96 views

Can two files in a directory be on different filesystems

I'm implementing atomic writes (FWIW in Python on Linux & FreeBSD), and I'm writing to a temporary file in the same directory with the file I'm planning to write to (in order to ensure that they ...
1
vote
2answers
173 views

mv complains about standard input in a pipeline that filters file name with grep

I'm trying to move several .avi files that have spaces in from a CD to my home folder. I've already know how to get rid of the spaces: find /media/mathscd/ | grep -L -r "*.avi" | for file in *; do ...
1
vote
0answers
63 views

Which Unixes support cross-device filesystem links (in particular for rename)?

Just read the following on the FreeBSD man page for the rename syscall: ... [EXDEV] The link named by to and the file named by from are on different logical devices (file systems). Note that ...
1
vote
3answers
98 views

How to rename files and directory with *.~1~ suffix to original name?

I have a directory named underscore.~1~ and several files inside with names like main.js.~1~, index.js.~1~ etc. How can I rename the directory underscore and the files inside to the original names ...
2
votes
1answer
181 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 ...
3
votes
3answers
340 views

Rename multiple files, sub directories, and insert characters at specific location on OSX

I have files and directories starting with "cateory-icon-" in many sub directories. I am trying to rename them recursively to "category-icons-". Please note that I added missing "g" to the category ...
1
vote
2answers
3k views

How to move files in sftp server?

How can I move a file in sftp server on a different directory? I connect to this server using sftp and then try to move a file using mv myfile.csv /my/dir/myfile.csv but this generates an error. ...
3
votes
2answers
453 views

How to copy multiple files but keep their extensions the same?

I am looping through a number of files, and $file represents the current file. How can I make copies or renames and keep the extension the same for this current file? e.g. if $file = x.jpg How to ...
3
votes
3answers
521 views

Rename the last 8 characters in filename

I am receiving video files with different names but the final 8 characters of all are numbers (also different every time). This is the pattern of the file name: custom text 00030402.avi I have to ...
1
vote
2answers
123 views

Why `rename` behaves differently whenever I use full path instead current path?

Ok, I'm answering a question where the OP have several repositories in Ubuntu that might be causing a problem installing unrelated software. I recommend disabling the PPA's using a single liner rename ...
4
votes
5answers
232 views

In Bash how does one determining the length of filename?

I'm doing a little script to rename some files. Actually a lot of files. The problem and the cool thing is, that I actually just need to change the files that have a filename length of 5 characters. ...
2
votes
1answer
552 views

Move a remote file at an FTP prompt

I don't think it's possible but still I would like to ask if there is any command to transfer a remote file from one directory to other at an FTP prompt. In more detail: I run ftp to a remote ...
6
votes
3answers
2k views

Rename files in the local folder adding a prefix or suffix

I have many files in a folder and I want to add either prefix or a suffix (not both) to them. I checked here and found out I can use for filename in *.jpg; do mv "$filename" "prefix_$filename"; done; ...
0
votes
2answers
1k views

How can I find files and then use xargs to move them?

I want to find some files and then move them. I can find the file with: $ find /tmp/ -ctime -1 -name x* I tried to move them to my ~/play directory with: $ find /tmp/ -ctime -1 -name x* | xargs ...
3
votes
2answers
858 views

Automatically moving files to a directory, one by one, and only when the target folder is empty

Is it possible? And in reverse alphabetical order? Essentially, this: How can I move files by type recursively from a directory and its sub-directories to another directory? Except that each file is ...
7
votes
3answers
479 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 ...
7
votes
3answers
373 views

cp or mv files to same directory they are already in when I am in another?

If I am in ~/blob and I have a file in ~/blob/a_long_directory_name/c/x.x I can type mv blob/a_long_directory_name/c/x.x blob/a_long_directory_name/even_more/y.y Is there any shortcut whereby I ...
2
votes
1answer
246 views

Renaming files based on the contents of a text file

I have lots of point files I need to change for model input. I want to rename lots of these files based on the contents of a file. These files are text files arranged in rows. file name: ...
5
votes
8answers
4k views

Is there a way to make “mv” fail silently?

A command like mv foo* ~/bar/ produces this message in stderr if there are no files matching foo*. mv: cannot stat `foo*': No such file or directory However, in the script I'm working on that case ...
6
votes
4answers
1k views

Bash script to rename files from a text file source

I'm fairly new to bash; I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as ...
3
votes
3answers
388 views

Batch rename files with unknown names and unknown extensions

I have a bunch of pictures, some are .jpg, some are .png. any given picture could have an entirely random name (possibly including spaces). in any given directory, how can I rename all of them, ...
4
votes
2answers
97 views

When I move a file to a different directory on the same partition, does the file's data actually move on disk?

I could see it going both ways. If the filesystem stores it's directory structure and list of files in each directory, and then points to the disk location of each of the files, it shouldn't require ...
2
votes
3answers
150 views

mv files to a different path which is constructed via a regex replacement

I have a directory full of files stored in subdirectories according to their filename, i.e.: 20d1/d325/52d1/20d1d32552d1a95249e62662fbdf924dd72c4027.jpg ...
1
vote
4answers
1k views

Change filename from lowercase to uppercase recursively

I have 1,000,000 files in some folders and subfolders. I want to rename them from lowercase to uppercase using shell commands. I don't want to modify the extension. only filename part. I have found ...
15
votes
3answers
2k views

What does `mv ./*` without specifying destination do?

I accidentally forgot to specify destination before hitting the Return key. Where does mv ./* without specifying destination move the files and directories under current directory to?
3
votes
1answer
1k views

Using regex in ls and mv

I have a directory structure like this ├── UK │   ├── BuyBand_go_UK.png │   ├── BuyBand_go_UK.svg │   ├── BuyBand_K.png │   ├── BuyBand_K.svg │   ├── BuyBago_UK.png │   ├── BuyBago_UK.svg │   ├── ...
0
votes
2answers
180 views

Keeps on getting message files are identical using find

Whenever I enter this: find . -type f -name 'diag*' -mtime +30 -exec mv {} temp_diag \; in SunOS I always get this message mv: ./temp_diag/diagnostic.log.68.gz and temp_diag/diagnostic.log.68.gz ...
1
vote
3answers
59 views

Rename directory from within directory?

How would I rename a directory from within that directory? For example: ~/tmp $ rn tmp2 ~/tmp2 $ I can do that with: cd .. && mv tmp tmp2 && cd tmp2, but not sure how to make it ...
1
vote
2answers
235 views

Unable to move or delete file with \r in the name

Somehow i have tar file called 'secret\r-.tar.gz'. Note that it has \r in the name. I tried following SSH command for moving but none of them are working: mv secret\r-.tar.gz ../ mv ...
1
vote
2answers
220 views

How batch mv files to folders created and named by modification date?

I am quite new to the terminal stuff and I just couldn't find any answer on the aforementioned subject. On my OS X, I have a folder with about 4000 pics that I'd like to move into folders that are ...
1
vote
1answer
207 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
2k 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
178 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
2answers
1k views

batch rename file names including spaces and patterns [duplicate]

I would like to rename a bunch of files which are named in a general form of, text1 text2 [firstname.lastname] text3 ... textn.ext I want to remove the text [firstname.lastname] from the name of a ...
2
votes
3answers
656 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. ...
3
votes
3answers
68 views

Can I forbid the creation of files with certain permissions?

I have a directory with a certain group ID, and I only want files with the same ID to be in that directory. So I set the SGID bit on that directory, so that everytime a file is created inside it, it ...