0

How to replace %002E with a dot(.) from all the directories and sub-directories name.

I tried the below command but it's not working

find . | rename -v "s/%002E/./g"

getting this error when I ran on a single file

Can't rename ./doc%002Ejson ./doc.json: Invalid cross-device link
Can't rename ./doc%002Ejson/fileData ./doc.json/fileData: No such file or directory
Can't rename ./doc%002Ejson/metadata ./doc.json/metadata: No such file or directory
Can't rename ./fontDef%002Ejson ./fontDef.json: Invalid cross-device link
Can't rename ./fontDef%002Ejson/fileData ./fontDef.json/fileData: No such file or directory
Can't rename ./fontDef%002Ejson/metadata ./fontDef.json/metadata: No such file or directory

edit: tired find -depth -type d | rename -n "s/%002E/./g" as well

I only see

rename(./doc%002Ejson, ./doc.json)
rename(./fontDef%002Ejson, ./fontDef.json)
rename(./listDef%002Ejson, ./listDef.json)
rename(./styleDef%002Ejson, ./styleDef.json)

but when I do ls I still see doc%002Ejson instead of doc.json

  • 1
    Does this answer your question? How to rename multiple files using find (just use -type d instead of -type f to only look for directories). – AdminBee Sep 24 '20 at 13:03
  • No. I tried with -type d. but getting this error: 'Can't rename ./doc%002Ejson ./doc.json: Invalid cross-device link Can't rename ./fontDef%002Ejson ./fontDef.json: Invalid cross-device link Can't rename ./listDef%002Ejson ./listDef.json: Invalid cross-device link Can't rename ./styleDef%002Ejson ./styleDef.json: Invalid cross-device link' – Vikas Rathore Sep 24 '20 at 13:19
  • Please try this and edit your question with the results find -depth -type d | rename -n "s/%002E/./g" – Chris Davies Sep 24 '20 at 13:45
  • What OS are you running this on? On my CentOS box, find . | rename -v "s/%002E/./g" returns: rename: not enough arguments. The command find . | xargs -l rename -v "%002E" "." seems to give me the results you are expecting. – spuck Sep 24 '20 at 14:58

0 Answers0