Skip to main content

All Questions

Tagged with
1 vote
1 answer
329 views

Passing argument of a function to exec in find

I would like to define a function to find and replace text in multiple files. I find the command line find . -type f -exec bash -c 'mv "$1" "${1/<string_to_find>/<...
opisthofulax's user avatar
3 votes
2 answers
420 views

How might one except hidden '.' files and directories from a script that renames them?

I have a script that renames, getting rid off the whitespace, every directory and file. It does it recursively: #!/bin/bash find -name "* *" -print0 | sort -rz | \ while read -d $'\0' f; ...
John Smith's user avatar
0 votes
0 answers
766 views

Bash: remove spaces in directory name [duplicate]

!! This question is not about SHELL, it's about BASH, can't change the faulty tag !! I've got a code that removes the spaces in directories and filenames (and inserts a dot); find $jdir -depth -name &...
JoBe's user avatar
  • 417
0 votes
2 answers
109 views

Rename recursively exluding the current directory

I use this command to rename files recursively: find -iname \*.bak | rename 's/.bak/.old/' But I want to exclude the current directory. Example: .bak dir1/.bak dir2/.bak ... After I want this: .bak ...
Mark's user avatar
  • 775
1 vote
0 answers
237 views

Renaming many files to their parent directory name [duplicate]

I want to recursively change many files named raw.tex to parent-directory-hw.tex. Is there a simple scripting solution to this problem? For example, running the script on . `-- root |-- baz |...
Brian Fitzpatrick's user avatar
2 votes
2 answers
164 views

how to increase the file extension numerically by one

under the following current folder, we have the example of files lok.log.1 df.log.6 weq.log.90 vr.log.11 vs.aw.frsd.log.3 we want to increase the files extension by 1 so the expected output will be ...
yael's user avatar
  • 13.9k
5 votes
3 answers
8k views

Remove particular word from filename

I have many files in a single folder like compose_icon_200x200.png mail_icon_200x200.png attach_icon_200x200.png delete_icon_200x200.png I want to remove the _200x200 from all filenames. I have tried ...
Arun's user avatar
  • 155
1 vote
0 answers
113 views

How to rename series episode files in folders to foldername using batch file [duplicate]

Looking for script or ? in terminal.. I have a directory named tv series with many series in it, example folder 24 hours - 24 episodes, in format S01E01.mkv-- S01E24.mkv. Would like to have it ...
Frank.W's user avatar
  • 11
-2 votes
2 answers
174 views

Rename a file in a folder based on presence of another file [closed]

The scenario I currently have is, I have multiple folders and each folder has traffic type (like ftp.csv, http.csv etc) and metrics (cpu.csv and memory.csv). folder1> cpu.csv http.csv folder2> cpu....
Karthick M's user avatar
1 vote
2 answers
182 views

How to rename certain directories if the parent has a particular name?

I have to do some global renaming in an Eclipse plugin project, although the fact that the code is Java and it's an Eclipse plugin is irrelevant. Basically, the steps I need to perform are the ...
David M. Karr's user avatar
7 votes
5 answers
4k views

Rename files based on their parent directory using find/xargs command?

I have a directory structure like this: Project/ | +--Part1/ | | | +--audio.mp3 | +--Part2/ | | | +--audio.mp3 | +--Part3/ | | | +--audio.mp3 ... I want to ...
mngeek206's user avatar
  • 3,058
1 vote
2 answers
1k views

Using rename to remove '.orig' from file and add '_1' to basename

I'm using a script to make backups of files, and to avoid overwriting files I've used cp --backup. Which leaves me with a number of files that look like example.mov.orig and test.mov.orig. I cannot ...
Richard Good's user avatar
9 votes
3 answers
7k views

How to remove space in all sub directories in shell script?

I tried following shell script to remove all spaces with underscores: find $1 -depth -name "* *" -print0 | \ while read -d $'\0' f; do mv -v "$f" "${f// /_}"; done If I have a directory /home/user/g ...
krishna's user avatar
  • 529
32 votes
4 answers
65k views

How to replace spaces in all file names with underscore in Linux using shell script?

I tried following shell script which should replace spaces from all xml filenames for xml_file in $(find $1 -name "* .xml" -type f); do echo "removing spaces from XML file:" $xml_file mv "$xml_file"...
krishna's user avatar
  • 529
1 vote
1 answer
553 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 ...
Alasdair's user avatar
  • 281

15 30 50 per page