How to rename all .jpg files in all subdirs wich contains dash in linux? [closed]

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








up vote
-1
down vote

favorite












I have subfolders with dashes (example subdir with name c-d). I need to rename all .jpg files in all subdirs. Any tips how to do it? I've tried many options, but nothing helped (I think because my subfolders contains dashes -) Thanks guys! :)



I have tried



find -name '*.jpg' -exec rename $RANDOM.jpg $RANDOM.jpg ;


but getting



(Missing operator before jpg?) syntax error at (user-supplied code)
line 3, near "2635.jpg" Bareword found where operator expected at
(eval 4) line 1, near "#line 1 2635.jpg"









share|improve this question















closed as unclear what you're asking by David Foerster, Zanna, Eric Carvalho, user68186, muru Feb 8 at 6:07


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 4




    What exactly is the intent of $RANDOM.jpg $RANDOM.jpg? rename expects a valid Perl expression telling it what to rename the files from and to
    – steeldriver
    Feb 6 at 13:58










  • I don't know because i've found it in the web. So how i can rename to a random name all .jpg files in all subdirs? Thanks for your answer, steeldriver
    – Jane Farrow
    Feb 6 at 14:01






  • 2




    Are you sure you want to rename all your Jpegs to something like XrUg2oCLIIoBGwH.jpg, l9OD0lus8Ft1LJ9.jpg, and 73k9qXms3rIH2Mr.jpg? I'm looking forward to reading a question about getting rid of files with weird names then.
    – PerlDuck
    Feb 6 at 14:17






  • 1




    Maybe the sybtax of the find should be find -name '*.jpg' -exec rename $RANDOM.jpg ; That will rename each .jpg file found () to the content of $RANDOM with .jpg added.
    – Soren A
    Feb 6 at 14:34






  • 4




    @SorenA That will rename all files to the same name because $RANDOM gets evaluated only once.
    – PerlDuck
    Feb 6 at 14:40














up vote
-1
down vote

favorite












I have subfolders with dashes (example subdir with name c-d). I need to rename all .jpg files in all subdirs. Any tips how to do it? I've tried many options, but nothing helped (I think because my subfolders contains dashes -) Thanks guys! :)



I have tried



find -name '*.jpg' -exec rename $RANDOM.jpg $RANDOM.jpg ;


but getting



(Missing operator before jpg?) syntax error at (user-supplied code)
line 3, near "2635.jpg" Bareword found where operator expected at
(eval 4) line 1, near "#line 1 2635.jpg"









share|improve this question















closed as unclear what you're asking by David Foerster, Zanna, Eric Carvalho, user68186, muru Feb 8 at 6:07


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 4




    What exactly is the intent of $RANDOM.jpg $RANDOM.jpg? rename expects a valid Perl expression telling it what to rename the files from and to
    – steeldriver
    Feb 6 at 13:58










  • I don't know because i've found it in the web. So how i can rename to a random name all .jpg files in all subdirs? Thanks for your answer, steeldriver
    – Jane Farrow
    Feb 6 at 14:01






  • 2




    Are you sure you want to rename all your Jpegs to something like XrUg2oCLIIoBGwH.jpg, l9OD0lus8Ft1LJ9.jpg, and 73k9qXms3rIH2Mr.jpg? I'm looking forward to reading a question about getting rid of files with weird names then.
    – PerlDuck
    Feb 6 at 14:17






  • 1




    Maybe the sybtax of the find should be find -name '*.jpg' -exec rename $RANDOM.jpg ; That will rename each .jpg file found () to the content of $RANDOM with .jpg added.
    – Soren A
    Feb 6 at 14:34






  • 4




    @SorenA That will rename all files to the same name because $RANDOM gets evaluated only once.
    – PerlDuck
    Feb 6 at 14:40












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have subfolders with dashes (example subdir with name c-d). I need to rename all .jpg files in all subdirs. Any tips how to do it? I've tried many options, but nothing helped (I think because my subfolders contains dashes -) Thanks guys! :)



I have tried



find -name '*.jpg' -exec rename $RANDOM.jpg $RANDOM.jpg ;


but getting



(Missing operator before jpg?) syntax error at (user-supplied code)
line 3, near "2635.jpg" Bareword found where operator expected at
(eval 4) line 1, near "#line 1 2635.jpg"









share|improve this question















I have subfolders with dashes (example subdir with name c-d). I need to rename all .jpg files in all subdirs. Any tips how to do it? I've tried many options, but nothing helped (I think because my subfolders contains dashes -) Thanks guys! :)



I have tried



find -name '*.jpg' -exec rename $RANDOM.jpg $RANDOM.jpg ;


but getting



(Missing operator before jpg?) syntax error at (user-supplied code)
line 3, near "2635.jpg" Bareword found where operator expected at
(eval 4) line 1, near "#line 1 2635.jpg"






command-line rename batch-rename






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 7 at 0:28









muru

130k19275470




130k19275470










asked Feb 6 at 13:52









Jane Farrow

1




1




closed as unclear what you're asking by David Foerster, Zanna, Eric Carvalho, user68186, muru Feb 8 at 6:07


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by David Foerster, Zanna, Eric Carvalho, user68186, muru Feb 8 at 6:07


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 4




    What exactly is the intent of $RANDOM.jpg $RANDOM.jpg? rename expects a valid Perl expression telling it what to rename the files from and to
    – steeldriver
    Feb 6 at 13:58










  • I don't know because i've found it in the web. So how i can rename to a random name all .jpg files in all subdirs? Thanks for your answer, steeldriver
    – Jane Farrow
    Feb 6 at 14:01






  • 2




    Are you sure you want to rename all your Jpegs to something like XrUg2oCLIIoBGwH.jpg, l9OD0lus8Ft1LJ9.jpg, and 73k9qXms3rIH2Mr.jpg? I'm looking forward to reading a question about getting rid of files with weird names then.
    – PerlDuck
    Feb 6 at 14:17






  • 1




    Maybe the sybtax of the find should be find -name '*.jpg' -exec rename $RANDOM.jpg ; That will rename each .jpg file found () to the content of $RANDOM with .jpg added.
    – Soren A
    Feb 6 at 14:34






  • 4




    @SorenA That will rename all files to the same name because $RANDOM gets evaluated only once.
    – PerlDuck
    Feb 6 at 14:40












  • 4




    What exactly is the intent of $RANDOM.jpg $RANDOM.jpg? rename expects a valid Perl expression telling it what to rename the files from and to
    – steeldriver
    Feb 6 at 13:58










  • I don't know because i've found it in the web. So how i can rename to a random name all .jpg files in all subdirs? Thanks for your answer, steeldriver
    – Jane Farrow
    Feb 6 at 14:01






  • 2




    Are you sure you want to rename all your Jpegs to something like XrUg2oCLIIoBGwH.jpg, l9OD0lus8Ft1LJ9.jpg, and 73k9qXms3rIH2Mr.jpg? I'm looking forward to reading a question about getting rid of files with weird names then.
    – PerlDuck
    Feb 6 at 14:17






  • 1




    Maybe the sybtax of the find should be find -name '*.jpg' -exec rename $RANDOM.jpg ; That will rename each .jpg file found () to the content of $RANDOM with .jpg added.
    – Soren A
    Feb 6 at 14:34






  • 4




    @SorenA That will rename all files to the same name because $RANDOM gets evaluated only once.
    – PerlDuck
    Feb 6 at 14:40







4




4




What exactly is the intent of $RANDOM.jpg $RANDOM.jpg? rename expects a valid Perl expression telling it what to rename the files from and to
– steeldriver
Feb 6 at 13:58




What exactly is the intent of $RANDOM.jpg $RANDOM.jpg? rename expects a valid Perl expression telling it what to rename the files from and to
– steeldriver
Feb 6 at 13:58












I don't know because i've found it in the web. So how i can rename to a random name all .jpg files in all subdirs? Thanks for your answer, steeldriver
– Jane Farrow
Feb 6 at 14:01




I don't know because i've found it in the web. So how i can rename to a random name all .jpg files in all subdirs? Thanks for your answer, steeldriver
– Jane Farrow
Feb 6 at 14:01




2




2




Are you sure you want to rename all your Jpegs to something like XrUg2oCLIIoBGwH.jpg, l9OD0lus8Ft1LJ9.jpg, and 73k9qXms3rIH2Mr.jpg? I'm looking forward to reading a question about getting rid of files with weird names then.
– PerlDuck
Feb 6 at 14:17




Are you sure you want to rename all your Jpegs to something like XrUg2oCLIIoBGwH.jpg, l9OD0lus8Ft1LJ9.jpg, and 73k9qXms3rIH2Mr.jpg? I'm looking forward to reading a question about getting rid of files with weird names then.
– PerlDuck
Feb 6 at 14:17




1




1




Maybe the sybtax of the find should be find -name '*.jpg' -exec rename $RANDOM.jpg ; That will rename each .jpg file found () to the content of $RANDOM with .jpg added.
– Soren A
Feb 6 at 14:34




Maybe the sybtax of the find should be find -name '*.jpg' -exec rename $RANDOM.jpg ; That will rename each .jpg file found () to the content of $RANDOM with .jpg added.
– Soren A
Feb 6 at 14:34




4




4




@SorenA That will rename all files to the same name because $RANDOM gets evaluated only once.
– PerlDuck
Feb 6 at 14:40




@SorenA That will rename all files to the same name because $RANDOM gets evaluated only once.
– PerlDuck
Feb 6 at 14:40










3 Answers
3






active

oldest

votes

















up vote
2
down vote













There is no case for rename, because you may just do it with mv.



find -name '*.jpg' -exec bash -c 'mv -i "" "$RANDOM.jpg"' ;


mv -i means interactive. It asks before overwriting.



This is not testet in depth, just ad hoc, to make sure files will get different names. A little more testing would be:



find -name '*.jpg' -exec echo bash -c 'mv -i "" "$RANDOM.jpg"' ;


However, this will put all files to the current dir. Maybe using -execdir is an option?



find -name '*.jpg' -execdir bash -c 'mv -i "" "$RANDOM.jpg"' ;


However, make a backup, be careful about your data and so on. Mass actions with find are a sharp instrument. I take no responsibility.



AFAIK dashes have no horses in this race.






share|improve this answer




















  • Especially the third one is perfect, but the purpose of this whole thing is still obscure. To me, at least.
    – PerlDuck
    Feb 6 at 17:14










  • This is the right approach IMHO except that you might consider bash -c 'for f; do mv -i -- "$f" "$RANDOM.jpg"; done' bash + (for efficiency, and to avoid expansion of the inside the command string). The OP could also consider using something like "$(mktemp --suffix=.jpg --tmpdir=. XXXXXX)" in place of $RANDOM since the latter is not guaranteed to be unique.
    – steeldriver
    Feb 6 at 17:17











  • Did you test for efficiency? What did you get? IMHO, this action will be harddrive limited, so trying to read and write at the same time might end up in worse performance. It's an additional layer of complexity, and I've learned to just do it right, and later care for performance, and only, if necessary. But I'm very interested in numbers, so if you have made some measurements, be invited! Because I hear such advice often, in connection with find ";" and +.
    – user unknown
    Feb 6 at 17:21


















up vote
0
down vote













You're unclear about how you want files to renamed. As far as which files to rename you can use find to match all files according you the desired pattern containing a dash:





find [PATH...] -type f -name '*-*' | prename EXPR


If you want to match directories too you need to use the -depth option:



find [PATH...] -depth -name '*-*' | prename EXPR





share|improve this answer


















  • 1




    I think the OP is mistakenly attributing the rename error to the fact that their directories have dashes in their names
    – steeldriver
    Feb 6 at 16:16

















up vote
0
down vote













I just tried this on sub-folders with a dash in their name, and it worked.



Renaming Portions of Filenames Recusively in Linux/Ubuntu



To rename files, you use the find command in conjunction with the rename command like this:



find -type f -execdir rename 's/OriginalText/NewText/' *.jpg '' ;


So if you want to replace all the dashes "-" in all the jpg filenames with underscores "_" then you would enter:



find -type f -execdir rename 's/-/_/' *.jpg '' ;





share|improve this answer





























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    There is no case for rename, because you may just do it with mv.



    find -name '*.jpg' -exec bash -c 'mv -i "" "$RANDOM.jpg"' ;


    mv -i means interactive. It asks before overwriting.



    This is not testet in depth, just ad hoc, to make sure files will get different names. A little more testing would be:



    find -name '*.jpg' -exec echo bash -c 'mv -i "" "$RANDOM.jpg"' ;


    However, this will put all files to the current dir. Maybe using -execdir is an option?



    find -name '*.jpg' -execdir bash -c 'mv -i "" "$RANDOM.jpg"' ;


    However, make a backup, be careful about your data and so on. Mass actions with find are a sharp instrument. I take no responsibility.



    AFAIK dashes have no horses in this race.






    share|improve this answer




















    • Especially the third one is perfect, but the purpose of this whole thing is still obscure. To me, at least.
      – PerlDuck
      Feb 6 at 17:14










    • This is the right approach IMHO except that you might consider bash -c 'for f; do mv -i -- "$f" "$RANDOM.jpg"; done' bash + (for efficiency, and to avoid expansion of the inside the command string). The OP could also consider using something like "$(mktemp --suffix=.jpg --tmpdir=. XXXXXX)" in place of $RANDOM since the latter is not guaranteed to be unique.
      – steeldriver
      Feb 6 at 17:17











    • Did you test for efficiency? What did you get? IMHO, this action will be harddrive limited, so trying to read and write at the same time might end up in worse performance. It's an additional layer of complexity, and I've learned to just do it right, and later care for performance, and only, if necessary. But I'm very interested in numbers, so if you have made some measurements, be invited! Because I hear such advice often, in connection with find ";" and +.
      – user unknown
      Feb 6 at 17:21















    up vote
    2
    down vote













    There is no case for rename, because you may just do it with mv.



    find -name '*.jpg' -exec bash -c 'mv -i "" "$RANDOM.jpg"' ;


    mv -i means interactive. It asks before overwriting.



    This is not testet in depth, just ad hoc, to make sure files will get different names. A little more testing would be:



    find -name '*.jpg' -exec echo bash -c 'mv -i "" "$RANDOM.jpg"' ;


    However, this will put all files to the current dir. Maybe using -execdir is an option?



    find -name '*.jpg' -execdir bash -c 'mv -i "" "$RANDOM.jpg"' ;


    However, make a backup, be careful about your data and so on. Mass actions with find are a sharp instrument. I take no responsibility.



    AFAIK dashes have no horses in this race.






    share|improve this answer




















    • Especially the third one is perfect, but the purpose of this whole thing is still obscure. To me, at least.
      – PerlDuck
      Feb 6 at 17:14










    • This is the right approach IMHO except that you might consider bash -c 'for f; do mv -i -- "$f" "$RANDOM.jpg"; done' bash + (for efficiency, and to avoid expansion of the inside the command string). The OP could also consider using something like "$(mktemp --suffix=.jpg --tmpdir=. XXXXXX)" in place of $RANDOM since the latter is not guaranteed to be unique.
      – steeldriver
      Feb 6 at 17:17











    • Did you test for efficiency? What did you get? IMHO, this action will be harddrive limited, so trying to read and write at the same time might end up in worse performance. It's an additional layer of complexity, and I've learned to just do it right, and later care for performance, and only, if necessary. But I'm very interested in numbers, so if you have made some measurements, be invited! Because I hear such advice often, in connection with find ";" and +.
      – user unknown
      Feb 6 at 17:21













    up vote
    2
    down vote










    up vote
    2
    down vote









    There is no case for rename, because you may just do it with mv.



    find -name '*.jpg' -exec bash -c 'mv -i "" "$RANDOM.jpg"' ;


    mv -i means interactive. It asks before overwriting.



    This is not testet in depth, just ad hoc, to make sure files will get different names. A little more testing would be:



    find -name '*.jpg' -exec echo bash -c 'mv -i "" "$RANDOM.jpg"' ;


    However, this will put all files to the current dir. Maybe using -execdir is an option?



    find -name '*.jpg' -execdir bash -c 'mv -i "" "$RANDOM.jpg"' ;


    However, make a backup, be careful about your data and so on. Mass actions with find are a sharp instrument. I take no responsibility.



    AFAIK dashes have no horses in this race.






    share|improve this answer












    There is no case for rename, because you may just do it with mv.



    find -name '*.jpg' -exec bash -c 'mv -i "" "$RANDOM.jpg"' ;


    mv -i means interactive. It asks before overwriting.



    This is not testet in depth, just ad hoc, to make sure files will get different names. A little more testing would be:



    find -name '*.jpg' -exec echo bash -c 'mv -i "" "$RANDOM.jpg"' ;


    However, this will put all files to the current dir. Maybe using -execdir is an option?



    find -name '*.jpg' -execdir bash -c 'mv -i "" "$RANDOM.jpg"' ;


    However, make a backup, be careful about your data and so on. Mass actions with find are a sharp instrument. I take no responsibility.



    AFAIK dashes have no horses in this race.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Feb 6 at 17:01









    user unknown

    4,80622151




    4,80622151











    • Especially the third one is perfect, but the purpose of this whole thing is still obscure. To me, at least.
      – PerlDuck
      Feb 6 at 17:14










    • This is the right approach IMHO except that you might consider bash -c 'for f; do mv -i -- "$f" "$RANDOM.jpg"; done' bash + (for efficiency, and to avoid expansion of the inside the command string). The OP could also consider using something like "$(mktemp --suffix=.jpg --tmpdir=. XXXXXX)" in place of $RANDOM since the latter is not guaranteed to be unique.
      – steeldriver
      Feb 6 at 17:17











    • Did you test for efficiency? What did you get? IMHO, this action will be harddrive limited, so trying to read and write at the same time might end up in worse performance. It's an additional layer of complexity, and I've learned to just do it right, and later care for performance, and only, if necessary. But I'm very interested in numbers, so if you have made some measurements, be invited! Because I hear such advice often, in connection with find ";" and +.
      – user unknown
      Feb 6 at 17:21

















    • Especially the third one is perfect, but the purpose of this whole thing is still obscure. To me, at least.
      – PerlDuck
      Feb 6 at 17:14










    • This is the right approach IMHO except that you might consider bash -c 'for f; do mv -i -- "$f" "$RANDOM.jpg"; done' bash + (for efficiency, and to avoid expansion of the inside the command string). The OP could also consider using something like "$(mktemp --suffix=.jpg --tmpdir=. XXXXXX)" in place of $RANDOM since the latter is not guaranteed to be unique.
      – steeldriver
      Feb 6 at 17:17











    • Did you test for efficiency? What did you get? IMHO, this action will be harddrive limited, so trying to read and write at the same time might end up in worse performance. It's an additional layer of complexity, and I've learned to just do it right, and later care for performance, and only, if necessary. But I'm very interested in numbers, so if you have made some measurements, be invited! Because I hear such advice often, in connection with find ";" and +.
      – user unknown
      Feb 6 at 17:21
















    Especially the third one is perfect, but the purpose of this whole thing is still obscure. To me, at least.
    – PerlDuck
    Feb 6 at 17:14




    Especially the third one is perfect, but the purpose of this whole thing is still obscure. To me, at least.
    – PerlDuck
    Feb 6 at 17:14












    This is the right approach IMHO except that you might consider bash -c 'for f; do mv -i -- "$f" "$RANDOM.jpg"; done' bash + (for efficiency, and to avoid expansion of the inside the command string). The OP could also consider using something like "$(mktemp --suffix=.jpg --tmpdir=. XXXXXX)" in place of $RANDOM since the latter is not guaranteed to be unique.
    – steeldriver
    Feb 6 at 17:17





    This is the right approach IMHO except that you might consider bash -c 'for f; do mv -i -- "$f" "$RANDOM.jpg"; done' bash + (for efficiency, and to avoid expansion of the inside the command string). The OP could also consider using something like "$(mktemp --suffix=.jpg --tmpdir=. XXXXXX)" in place of $RANDOM since the latter is not guaranteed to be unique.
    – steeldriver
    Feb 6 at 17:17













    Did you test for efficiency? What did you get? IMHO, this action will be harddrive limited, so trying to read and write at the same time might end up in worse performance. It's an additional layer of complexity, and I've learned to just do it right, and later care for performance, and only, if necessary. But I'm very interested in numbers, so if you have made some measurements, be invited! Because I hear such advice often, in connection with find ";" and +.
    – user unknown
    Feb 6 at 17:21





    Did you test for efficiency? What did you get? IMHO, this action will be harddrive limited, so trying to read and write at the same time might end up in worse performance. It's an additional layer of complexity, and I've learned to just do it right, and later care for performance, and only, if necessary. But I'm very interested in numbers, so if you have made some measurements, be invited! Because I hear such advice often, in connection with find ";" and +.
    – user unknown
    Feb 6 at 17:21













    up vote
    0
    down vote













    You're unclear about how you want files to renamed. As far as which files to rename you can use find to match all files according you the desired pattern containing a dash:





    find [PATH...] -type f -name '*-*' | prename EXPR


    If you want to match directories too you need to use the -depth option:



    find [PATH...] -depth -name '*-*' | prename EXPR





    share|improve this answer


















    • 1




      I think the OP is mistakenly attributing the rename error to the fact that their directories have dashes in their names
      – steeldriver
      Feb 6 at 16:16














    up vote
    0
    down vote













    You're unclear about how you want files to renamed. As far as which files to rename you can use find to match all files according you the desired pattern containing a dash:





    find [PATH...] -type f -name '*-*' | prename EXPR


    If you want to match directories too you need to use the -depth option:



    find [PATH...] -depth -name '*-*' | prename EXPR





    share|improve this answer


















    • 1




      I think the OP is mistakenly attributing the rename error to the fact that their directories have dashes in their names
      – steeldriver
      Feb 6 at 16:16












    up vote
    0
    down vote










    up vote
    0
    down vote









    You're unclear about how you want files to renamed. As far as which files to rename you can use find to match all files according you the desired pattern containing a dash:





    find [PATH...] -type f -name '*-*' | prename EXPR


    If you want to match directories too you need to use the -depth option:



    find [PATH...] -depth -name '*-*' | prename EXPR





    share|improve this answer














    You're unclear about how you want files to renamed. As far as which files to rename you can use find to match all files according you the desired pattern containing a dash:





    find [PATH...] -type f -name '*-*' | prename EXPR


    If you want to match directories too you need to use the -depth option:



    find [PATH...] -depth -name '*-*' | prename EXPR






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 6 at 16:19

























    answered Feb 6 at 15:47









    David Foerster

    26.5k1362106




    26.5k1362106







    • 1




      I think the OP is mistakenly attributing the rename error to the fact that their directories have dashes in their names
      – steeldriver
      Feb 6 at 16:16












    • 1




      I think the OP is mistakenly attributing the rename error to the fact that their directories have dashes in their names
      – steeldriver
      Feb 6 at 16:16







    1




    1




    I think the OP is mistakenly attributing the rename error to the fact that their directories have dashes in their names
    – steeldriver
    Feb 6 at 16:16




    I think the OP is mistakenly attributing the rename error to the fact that their directories have dashes in their names
    – steeldriver
    Feb 6 at 16:16










    up vote
    0
    down vote













    I just tried this on sub-folders with a dash in their name, and it worked.



    Renaming Portions of Filenames Recusively in Linux/Ubuntu



    To rename files, you use the find command in conjunction with the rename command like this:



    find -type f -execdir rename 's/OriginalText/NewText/' *.jpg '' ;


    So if you want to replace all the dashes "-" in all the jpg filenames with underscores "_" then you would enter:



    find -type f -execdir rename 's/-/_/' *.jpg '' ;





    share|improve this answer


























      up vote
      0
      down vote













      I just tried this on sub-folders with a dash in their name, and it worked.



      Renaming Portions of Filenames Recusively in Linux/Ubuntu



      To rename files, you use the find command in conjunction with the rename command like this:



      find -type f -execdir rename 's/OriginalText/NewText/' *.jpg '' ;


      So if you want to replace all the dashes "-" in all the jpg filenames with underscores "_" then you would enter:



      find -type f -execdir rename 's/-/_/' *.jpg '' ;





      share|improve this answer
























        up vote
        0
        down vote










        up vote
        0
        down vote









        I just tried this on sub-folders with a dash in their name, and it worked.



        Renaming Portions of Filenames Recusively in Linux/Ubuntu



        To rename files, you use the find command in conjunction with the rename command like this:



        find -type f -execdir rename 's/OriginalText/NewText/' *.jpg '' ;


        So if you want to replace all the dashes "-" in all the jpg filenames with underscores "_" then you would enter:



        find -type f -execdir rename 's/-/_/' *.jpg '' ;





        share|improve this answer














        I just tried this on sub-folders with a dash in their name, and it worked.



        Renaming Portions of Filenames Recusively in Linux/Ubuntu



        To rename files, you use the find command in conjunction with the rename command like this:



        find -type f -execdir rename 's/OriginalText/NewText/' *.jpg '' ;


        So if you want to replace all the dashes "-" in all the jpg filenames with underscores "_" then you would enter:



        find -type f -execdir rename 's/-/_/' *.jpg '' ;






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 7 at 17:59

























        answered Feb 7 at 3:02









        SunnyDaze

        82128




        82128












            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491