Remove the last 15 characters of a filename with respect to leave file extension


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove the last 15 characters of a filename with respect to leave file extension
# 8  
Old 12-28-2013
we can do this

Code:
echo $(echo "VFX_Official_Trailer_(HD)__Shhh__-_by_Freddy_Chavez_Olmos_&_Shervin_Shoghian-[YT-f22][Ht2aZLf8q_8].mp4" | rev | awk -F. '{print $NF}' | cut -c 23- | rev).mp4

# 9  
Old 12-30-2013
How about this ?
Code:
 echo "VFX_Official_Trailer_(HD)__Shhh__-_by_Freddy_Chavez_Olmos_&_Shervin_Shoghian-[YT-f22][Ht2aZLf8q_8].mp4" | tr -c -s "[[:alnum:]]" "-"  | awk '{a=substr($0,length($0)-3,3);print substr($0,1,length($0)-27)"."a}'

# 10  
Old 12-30-2013
Code:
# echo $mp4
VFX_Official_Trailer_(HD)__Shhh__-_by_Freddy_Chavez_Olmos_&_Shervin_Shoghian-[YT-f22][Ht2aZLf8q_8].mp4

# echo "$mp4"| ruby -e 's=gets; puts s.gsub(/[&-]+/,"_").gsub(/_+/,"-").split("-")[0..-4].join("-") + ".mp4" '
VFX-Official-Trailer-(HD)-Shhh-by-Freddy-Chavez-Olmos-Shervin-Shoghian.mp4

# 11  
Old 02-08-2014
how can i remove none English letters from renamed file name
# 12  
Old 02-08-2014
Quote:
Originally Posted by ateya
how can i remove none English letters from renamed file name
Is this related to the initial problem introduced in this thread? (If not, please start a new thread with a title related to what you are trying to do and provide a better description along with examples of the file name transformations you want to perform.)

What do you mean by "remove none English letters"? Are you saying that you want to remove everything from a file's name except the 52 uppercase and lowercase letters available in the C Locale? Do you mean that you want to change a filename like VFX_Official_Trailer_(HD)__Shhh__-_by_Freddy_Chavez_Olmos_&_Shervin_Shoghian-[YT-f22][Ht2aZLf8q_8].mp4 into VFXOfficialTrailerHDShhhbyFreddyChavezOlmosShervinShoghianYTfHtaZLfqmp
# 13  
Old 02-23-2014
sometimes the video name contains no English letters (non English language)
like
korian
Japaneses
arabic
# 14  
Old 02-23-2014
So, if you have a filename like <arabic string>-[YT-f23][Ht3aZLf9q_7].mp4, you want the entire filename to be turned into .mp4? Assuming this isn't what you want, please give us clear directions of the changes you want made to the filenames you're processing (similar to what I provided in message #4 in this thread with your new requirements added) and show us examples of what you do want to happen.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove filename from output file?

Hello, I am trying to print searched multiple keywords in multiple files. It is almost okay with the code but the code puts filename in front of each line. How may I get rid of it? -grep -A1 'word1' *.txt | grep -A1 'word2' | grep -A1 'word3' I expect: Real outcome: How may I... (3 Replies)
Discussion started by: baris35
3 Replies

2. Shell Programming and Scripting

Remove the last 9 characters of a filename

Hi All! Please can someone help, I have a dir with the following files: ~-rw-r--r-- 1 emmuser users 2087361 Oct 16 15:50 MPGGSN02_20131007234519_24291.20131007 -rw-r--r-- 1 emmuser users 2086837 Oct 16 15:50 MPGGSN02_20131007233529_24272.20131007 -rw-r--r-- 1 emmuser ... (7 Replies)
Discussion started by: fretagi
7 Replies

3. Shell Programming and Scripting

Remove the file except with particular extension

Hi all i am new for the shell scripting can any one help me with my requirments . i want to delete file older than 21 days everything works fine but in that dir i got the files with should not be deleted with particular extension like (.info):confused:here is the script i wrote .can anyone... (5 Replies)
Discussion started by: vikatakavi
5 Replies

4. Shell Programming and Scripting

Filename rename with characters of file

Hi, I need a bit of help. I've used awk to get the first 7 characters of a file - awk '{print substr($0,0,7)}' test.csv How do I now take this variable to rename test.csv to variable.csv ? Any help or advice would be greatly appreciated! (2 Replies)
Discussion started by: sianm
2 Replies

5. Shell Programming and Scripting

[Solved] remove file extension

Hi, I have some files with some extension e.g. abc.xml.REMOVE,xyz.xml,efg.xml.REMOVE . I have to remove the .REMOVE extension. I can display it using the below script but cannot rename it. ls -l|sed 's/\.REMOVE//' How can I rename this? Thanks in advance (7 Replies)
Discussion started by: babom
7 Replies

6. Shell Programming and Scripting

Remove filename is text file

Hello, I got files full path in a text file like that /main/k/kdelibs/kdelibs4c2a_3.5.10.dfsg.1-2ubuntu7_i386.deb /main/k/kdelibs-experimental/libknotificationitem-dev_4.3.2-0ubuntu1_i386.deb /main/k/kdemultimedia/dragonplayer_4.3.2-0ubuntu1_i386.deb... (13 Replies)
Discussion started by: davidkhan
13 Replies

7. Shell Programming and Scripting

sed script to remove nth characters from end of filename

Hi all, I have this basic script to remove, in this case 9 characters from the end of a file name. This is what I have so far, for file in *.mov do newname=`echo $file | sed 's/\(.*\)........./\1/' ` mv "$file" "$newname" done The problem is that it removes the file extension as well.... (2 Replies)
Discussion started by: Monkey Dean
2 Replies

8. Shell Programming and Scripting

remove special characters from filename recursively

hi: i have several thousand files from users and of course they use all kind of characters on filenames. I have things like: My special report (1999 ) Lisa & Jack's work.doc crazy. How do I remove all this characters in the current dir and subdirs too? Thanks. (3 Replies)
Discussion started by: jason7
3 Replies

9. Shell Programming and Scripting

remove file extension

Hi ALL, I'm new to this forum. Thanks and congrats to all for their great efforts building this site simply superb for all unix administrators. My requirement is to remove extensions of the files in the current directory. I'm doing it using below script which is working but i think it is... (12 Replies)
Discussion started by: prvnrk
12 Replies

10. Shell Programming and Scripting

Need to only remove parenthesis and : leave the rest

Hi all, I'm stuck on this last part...am running a simple script under AIX to extract NetView host IP addresses. The line below returns the IP address in parenthesis with a trailing colon, i.e. ping -c 1 $name |grep \( | awk '{ print $3 }' --------> returns (a.b.c.d): How can I only... (10 Replies)
Discussion started by: livinthedream
10 Replies
Login or Register to Ask a Question