Removing digits from beginning of filename

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I was hoping this would work:



$ find . -type f -exec basename ; | while EFS= read -r f; do echo "$f##[0-9]"; done 


But, for example, for files named as:




1foo

11bar




it returns:




foo

1bar




when




foo

bar




is expected.



PS: ultimately, I want to mv "$f" to the modified name (and also do other modifications)










share|improve this question



















  • 1




    Your code is telling it , in effect, to remove 0-9 from the beginning of the filename. If there is more than one digit (two, for example) then you need to change [0-9] to [0-99]. For three, you need [0-999] and so on and so forth.
    – Nasir Riley
    11 mins ago










  • The title says "beginning of file" but your code is gathering filenames and then renaming them. Also, unsetting "EFS" appears to be a typo for unsetting "IFS"
    – Jeff Schaller
    6 mins ago










  • Your solution necessitates to know in advance the number of digits. Is there not a more general way? Why doesn't ## take care of it in the parameter expansion?
    – Erwann
    6 mins ago










  • Yes, I meant filename, sorry.
    – Erwann
    5 mins ago






  • 1




    Do you care how it's done? Do you have a "rename" utility installed?
    – Jeff Schaller
    4 mins ago














up vote
0
down vote

favorite












I was hoping this would work:



$ find . -type f -exec basename ; | while EFS= read -r f; do echo "$f##[0-9]"; done 


But, for example, for files named as:




1foo

11bar




it returns:




foo

1bar




when




foo

bar




is expected.



PS: ultimately, I want to mv "$f" to the modified name (and also do other modifications)










share|improve this question



















  • 1




    Your code is telling it , in effect, to remove 0-9 from the beginning of the filename. If there is more than one digit (two, for example) then you need to change [0-9] to [0-99]. For three, you need [0-999] and so on and so forth.
    – Nasir Riley
    11 mins ago










  • The title says "beginning of file" but your code is gathering filenames and then renaming them. Also, unsetting "EFS" appears to be a typo for unsetting "IFS"
    – Jeff Schaller
    6 mins ago










  • Your solution necessitates to know in advance the number of digits. Is there not a more general way? Why doesn't ## take care of it in the parameter expansion?
    – Erwann
    6 mins ago










  • Yes, I meant filename, sorry.
    – Erwann
    5 mins ago






  • 1




    Do you care how it's done? Do you have a "rename" utility installed?
    – Jeff Schaller
    4 mins ago












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I was hoping this would work:



$ find . -type f -exec basename ; | while EFS= read -r f; do echo "$f##[0-9]"; done 


But, for example, for files named as:




1foo

11bar




it returns:




foo

1bar




when




foo

bar




is expected.



PS: ultimately, I want to mv "$f" to the modified name (and also do other modifications)










share|improve this question















I was hoping this would work:



$ find . -type f -exec basename ; | while EFS= read -r f; do echo "$f##[0-9]"; done 


But, for example, for files named as:




1foo

11bar




it returns:




foo

1bar




when




foo

bar




is expected.



PS: ultimately, I want to mv "$f" to the modified name (and also do other modifications)







find rename parameter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 min ago









Jeff Schaller

34.4k951114




34.4k951114










asked 1 hour ago









Erwann

268




268







  • 1




    Your code is telling it , in effect, to remove 0-9 from the beginning of the filename. If there is more than one digit (two, for example) then you need to change [0-9] to [0-99]. For three, you need [0-999] and so on and so forth.
    – Nasir Riley
    11 mins ago










  • The title says "beginning of file" but your code is gathering filenames and then renaming them. Also, unsetting "EFS" appears to be a typo for unsetting "IFS"
    – Jeff Schaller
    6 mins ago










  • Your solution necessitates to know in advance the number of digits. Is there not a more general way? Why doesn't ## take care of it in the parameter expansion?
    – Erwann
    6 mins ago










  • Yes, I meant filename, sorry.
    – Erwann
    5 mins ago






  • 1




    Do you care how it's done? Do you have a "rename" utility installed?
    – Jeff Schaller
    4 mins ago












  • 1




    Your code is telling it , in effect, to remove 0-9 from the beginning of the filename. If there is more than one digit (two, for example) then you need to change [0-9] to [0-99]. For three, you need [0-999] and so on and so forth.
    – Nasir Riley
    11 mins ago










  • The title says "beginning of file" but your code is gathering filenames and then renaming them. Also, unsetting "EFS" appears to be a typo for unsetting "IFS"
    – Jeff Schaller
    6 mins ago










  • Your solution necessitates to know in advance the number of digits. Is there not a more general way? Why doesn't ## take care of it in the parameter expansion?
    – Erwann
    6 mins ago










  • Yes, I meant filename, sorry.
    – Erwann
    5 mins ago






  • 1




    Do you care how it's done? Do you have a "rename" utility installed?
    – Jeff Schaller
    4 mins ago







1




1




Your code is telling it , in effect, to remove 0-9 from the beginning of the filename. If there is more than one digit (two, for example) then you need to change [0-9] to [0-99]. For three, you need [0-999] and so on and so forth.
– Nasir Riley
11 mins ago




Your code is telling it , in effect, to remove 0-9 from the beginning of the filename. If there is more than one digit (two, for example) then you need to change [0-9] to [0-99]. For three, you need [0-999] and so on and so forth.
– Nasir Riley
11 mins ago












The title says "beginning of file" but your code is gathering filenames and then renaming them. Also, unsetting "EFS" appears to be a typo for unsetting "IFS"
– Jeff Schaller
6 mins ago




The title says "beginning of file" but your code is gathering filenames and then renaming them. Also, unsetting "EFS" appears to be a typo for unsetting "IFS"
– Jeff Schaller
6 mins ago












Your solution necessitates to know in advance the number of digits. Is there not a more general way? Why doesn't ## take care of it in the parameter expansion?
– Erwann
6 mins ago




Your solution necessitates to know in advance the number of digits. Is there not a more general way? Why doesn't ## take care of it in the parameter expansion?
– Erwann
6 mins ago












Yes, I meant filename, sorry.
– Erwann
5 mins ago




Yes, I meant filename, sorry.
– Erwann
5 mins ago




1




1




Do you care how it's done? Do you have a "rename" utility installed?
– Jeff Schaller
4 mins ago




Do you care how it's done? Do you have a "rename" utility installed?
– Jeff Schaller
4 mins ago















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477613%2fremoving-digits-from-beginning-of-filename%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477613%2fremoving-digits-from-beginning-of-filename%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?