General :: How To Rename Everything Matching Certain String In Folder

May 19, 2010

I am running Linux and I have some basic console knowledge but my current problem is quite difficult and I dont know how to achieve this. I want/need to rename everything within a folder that matches a given string.

By everything I mean:
folders/files
content within a file
content in hidden files

Basically I want to refactor a Java-project. Sure, I could use Eclipse to handle the replacing, but this leaves out the folders or resources outside of my workspace. I was thinking of a script that could do the job for me but this seems rather tricky. For instance when it comes to folder-/file-rename I want to replace only the part of the name that matches my string, the rest should remain untouched.

View 2 Replies


ADVERTISEMENT

Programming :: Rename Files Matching A List?

Jul 12, 2009

Is there a way, preferably in python or BASH, to rename files from a list? for instance, track1.mp3, track2.mp3 should be renamed to the names stored in a file listing song names. I have tried to loop a variable through directory listing and renamed them, only to find that filenames with spaces can't be assigned to a variable as a whole. To solve the problem above, I have tried the read command in BASH, which enables the program reading line by line from a list. However, It was failed to pipe the results from directory listing to the read command.

View 14 Replies View Related

General :: Remove A Folder : Getting An Error : Unexpected EOF While Looking For Matching?

Apr 8, 2011

I tried to remove a folder in linux, davidanderson'spetshop_617 as a folder name. It contained a single quotes. By using the following command

rm -r path/davidanderson'spetshop_617

I am getting this error ,Error: unexpected EOF while looking for matching `''unexpected end of files.How can i remove the folder?

View 2 Replies View Related

Programming :: Delete Line In File Matching String?

Jan 26, 2010

Quote:Originally Posted by topcatI would like to know how i can write a shell script to delete a line if a particular pattern exists?E.g. I have a text file with multiple lines. Say 1000s. in the following pattern.

username@email.com:149.0.3.4:1
username1@email.com:149.0.3.4:1
username1@email.net:149.0.3.4:1
username1@email.edu:149.0.3.4:1

If the patternusername@email.com exists then the line "username@email.com:149.0.3.4:1 should be deleted from the file.I have a very similar question but I need to delete one line in a file which matches one very precise instance of a string only. Let's assume I have a file composed of thousands of lines and let's call the file chap-secrets. Let's take the following sample entries:

Code:
#USERNAME SERVER PASSWORD IP
pp pptpd blahblah *

[code]....

View 7 Replies View Related

General :: How To Rename Music Folder Indicating Bitrate

May 3, 2011

I have a large collection of music albums sorted in folders which are named like this: "Zombie Ritual - 2004 - Night Of The Zombie Party" (%{artist} - %{year} - %{album}). I want to rename them so as to be indicative of the bitrate, for example, "Zombie Ritual - 2004 - Night Of The Zombie Party" => "Zombie Ritual - 2004 - Night Of The Zombie Party (@320)". It will be hard to do this manually. I tried to use EasyTag and Kid3 to do this, but they cannot add bitrate to tags.

View 6 Replies View Related

General :: Ubuntu - Rename Home Folder Structure To System Language?

Oct 14, 2010

I have installed the Ubuntu distro first in Portuguese. Then, I decided I wanted the English language. I would like that the default folders like "Desktop" and "Documents" were renamed to this names, instead of staying in their Portuguese equivalent.

I can not guarantee this, but I am almost certain I did successfully convert the folder names from Portuguese to English on a previous install when I decided to change the language. So, I suppose this is possible.

View 1 Replies View Related

General :: Searching A Particular String In All Files Of A Single Folder?

Jun 27, 2011

I just want to know if we can search for a particular string in all files of a particular folder in linux. if a folder has 100files only that hundred files needs to be checked for a particular string.

View 5 Replies View Related

Ubuntu :: How To Rename Folder [space]

Feb 28, 2010

How to rename folder which contain space in foldername

Path : /root/Documents/untitled folder

I want to replace space with undersope how to do that

Output : /root/Documents/untitled_folder

through terminal any idea ?

View 9 Replies View Related

Ubuntu :: Rename All Files In Folder?

Oct 14, 2010

I have this script:

Quote:

for f in d*; do mv "$f" "T${f#d}"; done

it outputs all files which strats with letter d to T but it doesn't work when i run it from Cron. It only affect root file / .

How i can make work like this:

/home/user/files/dfile.txt
=>
/home/user/files/Tfile.txt

View 2 Replies View Related

Fedora :: Rename All Image Files To Folder.jpg?

Sep 26, 2009

I have all my music on an external HD and the filename and path of each file is in the format of the following

Code:
Ex HD Root / Music / Artist / Album / Artist - Album - Track No - Track Name.mp3
OCD I know

[code]...

View 2 Replies View Related

Ubuntu :: Rename Files - Add Number To All In Folder ?

Feb 14, 2010

Getting together a script that will add numbers to all the files in a folder.

I've ripped most of my CDs to oggs for my new pmp, but I found that the pmp doesn't like files that are numbered just as 1 and 2, as it thinks that the 2 is more than 10.

So instead of going through all of my music folders and renaming every file by hand from 1 to 01 and from 2 to 02, I'd ask if there's a script that can be executed to add these numbers for me. It'd be even better if it only added the number to the files with only one digit.

Here's an example:

I want to rename:

And I'd like to do it to all single-digit files lower than 10 in the folder, if possible. If not, I can isolate them by hand.

View 4 Replies View Related

Software :: Rsync - Not Re-transfer After Folder Rename?

Jun 25, 2010

I have a feeling that there is no answer to this issue but I'll try.I have an rsync server running. If I rename a folder, rsync will re-transfer all the files under that folder. Does anyone know if there's any automated way around this ?

View 1 Replies View Related

Ubuntu :: Rename - Add Suffix Or Prefix In All Files (.txt - .avi . - .exe) From A Folder

Feb 24, 2010

I want to add suffix or prefix in all files (.txt , .avi . , .exe)from a folder

View 9 Replies View Related

Programming :: Matching Two Tables Of Non-matching Sizes?

Mar 2, 2011

I have two table files with x (1st column) ,y (2nd column) coordinates and intensity (3rd column). I need to match these two tables and divide the intensities at the consecutive coordinates on the 3rd column. The problem is the size of the tables are not same and I want to ignore the lines if they are not in one of the other file.

Here is Table 1:

Code:
-7.500-30.00013.006
-7.500-22.50037.952
-7.500-15.00060.962
-7.500-7.50040.922
-7.5000.00014.348
code....

View 3 Replies View Related

Ubuntu Multimedia :: Rename All JPEGs In A Folder By EXIF Date & Time Stamp?

Feb 24, 2011

In the Windows world where I came from, Irfanview freeware easily renamed a large folder of JPEG photos by EXIF time & date stamps, appending a unique number if the time and date stamps were the same. Is there an equivalent rename-by-EXIF information batch command in Ubuntu 10.04 Lucid? For example, change (based solely on EXIF information): FROM:DSC_0001.JPG TO:20110224_09:34:56am.JPG

View 9 Replies View Related

Programming :: Copy String A To String B And Change String B With Toupper() And Count The Chars?

Oct 22, 2010

copy string a to string b and change string b with toupper() and count the chars

View 3 Replies View Related

General :: Replace String With Empty String Of Dir Path ?

Apr 2, 2011

I want to replace a string of directory path in a string to empty:

Code:

But this doesnt seem to give me the desired thing:

Code:

This gives the desired outcome, but its specific, i need a variable in the sed not a string. And if I replace STRING="/mnt/sda1/record/$dd/" then I cant use it for something else, cause its has all the weird backslashes now.

View 3 Replies View Related

Software :: Filter Command For Replacing A String In A Folder?

Mar 5, 2010

I am having a folder which is having 155 files, i have replace a string with a different string.How can i do it?

View 1 Replies View Related

General :: Extract A String Within A String Using A Pattern?

Nov 4, 2010

i have a file name using the following pattern:

PREFIX: AR
SOURCE: LEGACY
DATETIME: YYYYMMDD_HH24MISS
SUFFIX: .txt

sample filename:AR_LEGACY_20101104_105500.txti want to extract the source which is LEGACY in this case. how do i do this using shell?

View 1 Replies View Related

Ubuntu :: Hide Folders Or Files Without Adding Period "." To Rename File Or Folder

Jun 18, 2011

I am trying to hide some folders in Ubuntu Linux which are always hidden in Windows through File/Folder Attributes (attrib -h)

It is not an option for me to rename the folder from let's say "Ancient texts directory" to ".Ancient Texts Directory" because the programs associated with these files and shortcuts will not work in Windows. I would like to make the folder hidden by not renaming the folder. Is that so hard to ask?

Is there really no other way of making a folder or a file hidden in Linux just like in Windows by Applying Attributes? I Don't want to rename it by putting a dot in front of it. Moreover renaming a file by putting a dot in front of the name changes the position the folder appears in the list view. For some people this may be ridiculous, but for me with a few hundred files and folders and subfolders, this organisation is important, aside from the aforementioned reasons.

I need to maintain compatibility between the two operating systems' basic folder structure as i must use both Operating systems.

View 9 Replies View Related

General :: Awk Gsub() Command - String (column) Manipulation - Replace The Value Of The $1 Column In The Awk Print String?

Mar 7, 2010

i use this script to get the time and date of back and fourth transactions for a particular execution id. I use a substr command on the 5th column to to cut the milli seconds off the time value. - otherwise the times would look like 08:30:04.235

grep <executionID> <auditfile> | awk '{ print $1, $2, $3, $4, substr($5,1,8}
FIX -> Mon 3/1/2010 08:30:04
FIX <- Mon 3/1/2010 08:32:36
FIX <- Mon 3/1/2010 08:35:08

[code].....

anyhow - i append two sed commands to further clarify the direction of the message.

awk '{ print $1, $2, $3, $4, substr($5,1,8} | sed -e 's/->/ ->IN/g' | sed -e 's/<-/<-OUT/g'
FIX -> IN Mon 3/1/2010 08:30:04
FIX <- OUT Mon 3/1/2010 08:32:36

[code]....

I tried using an awk gsub () command within the string instead of the two seds, but it did not work:

awk '{ print gsub(/<regex>/, <replace with>,$1), $2, $3, $4, substr($5,1,8}

the sed works ok, but it would be cooler to make the replacement within the awk command:

gsub(/->/,-> IN, $1)

Is there a way where i could replace the value of the $1 column in the awk print string?

View 1 Replies View Related

General :: String Replace In Filenames - Files Already Contain The String "Soundtrack"

Jun 11, 2011

Moving right along, I have a folder of MP3 files containing various Movie sound tracks and scores. I'm using Audio Tag Tool to tag all the files at once with an "Artist" of "Soundtrack", and to inherit the "Title" tag from the file name. After that, I will rename all the files (Using Audio Tag Tool -- awesome program, btw) with the format "<Artist> - <Title>.mp3"

The problem, is many of my files already contain the string "Soundtrack", which would be redundant. I happen to be a perfectionist, so I'm unable to ignore it and move on. Hence my question to you fine folk: I want to delete all instances of "soundtrack" (-i case irrelevant) in the filenames before I go through the above steps. But, its not quite that simple. This is a sample of some of the file names:

[Code]....

View 3 Replies View Related

General :: Use Awk To Matching In Only A Specific Column?

Jul 12, 2010

Im trying to use awk to do matching in only a specific column

example.txt:
www.google.com www.example.com
www.google.com/search www.example2.com
i used:
awk '{ (if $1 == "http://www.google.com") print $2}' example.txt

this awk statement only returns the first line, and i cant seems to make it perform in a way to match based on keywords like GREP. Is there any way to make display the other lines which contains "google" also?

View 1 Replies View Related

Software :: Rename Hidden Files / Rename All Files With A Leading Decimal Point Recursivley?

Jul 25, 2011

How would I rename all files with a leading decimal point recursivley? I some how got all my music files to have a decimal point.I tried the below and got a " sed argument to long".[CODE]find /media/MUSIC -type f -name "*.wma" | xargs -0 sed -i 's/.(.*)/1/'[CODE]

Another question, can i just use -type f with out -name ? I am sure that all the files got the decimal point added as the first character.

View 14 Replies View Related

General :: Listing Files Using Pattern Matching

Mar 13, 2011

I have a requirement to list files using find command My folder contains below list of files with out extention.I have a requirement to exclude only ABC.123.* type files and list others. Even though files having MNO contains this pattern i should not exclude. Even if file ends with .txt or .doc it should not be excluded. That is ABC.123.1234.txt should not be excluded.But I am not getting what is required. Can any one please let me know if I am doing wrong any where. As per my requirement I cannot use grep, -regex, or -regex attributes to find command.

View 7 Replies View Related

General :: Delete Matching Files In All Subdirectories?

Feb 22, 2010

How can I remove all .swp files in all of my subdirectories under Linux?

View 4 Replies View Related

General :: Copy All Files Matching Pattern From SRC To DST

Jul 19, 2011

If I wanted to copy all *.so files from src to dst I'd do:
cp src/*.so dst
However, I want to copy all *.so files from src and it's subdirs into dst.

View 2 Replies View Related

General :: Grep Or Sed To Delete Matching Pattern?

Jul 7, 2011

How can I use grep -Ev "pattern" not only to delete the matching "pattern" but to edit and save the file permanently as well

View 2 Replies View Related

General :: Cross Reference Matching Between Files?

Oct 18, 2009

I'm trying to do something very basic in bash. It's a kind of cross-reference matching between 2 files. I have a file1.txt. It's like this:

Code:

item1
item3
item4
...

I Have a file2.txt. It's like this:

Code:

item1 "Properties of item1"
item2 "Properties of item2"
item3 "Properties of item3"
item4 "Properties of item4"
item5 "Properties of item5"
...

My goal is to print out the lines in file2 that contains lines present in file1. I do:

Code:

for i in $(cat file1.txt); do grep $i file2.txt; done but I get no output. Will someone please tell me where am I mistaking?

View 3 Replies View Related

General :: Boot Menu Not Matching Grub.cfg?

Feb 1, 2011

I had debian squeeze already installed, then installed win 7. Windows overwrote by MBR, as I expected it to, so I used an ubuntu live cd to reinstall grub2 to debian root.

I rebooted, and sure enough I had grub back. The boot menu has debian on it. Just debian (crunchbang actually, but its the same thing).

So I added a script in /etc/grub.d (called Windows_11) to create a windows chainloader entry in grub.cfg, and ran update-grub.

Update-grub picks up my /etc/grub.d/Windows_11 script, and adds an appropriate chainloader entry to /boot/grub/grub.cfg.

So I would expect this new chainloader entry to show up in my boot menu when I boot up. But it doesn't; on booting I only have the option to select debian.

Here is my /boot/grub/grub.cfg -

Code:
### BEGIN /etc/grub.d/10_linux ###
menuentry 'CrunchBang Linux, with Linux 2.6.32-5-686' --class crunchbang --class gnu-linux --class gnu --class os {
insmod part_msdos

[Code].....

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved