Skip to main content
added 98 characters in body
Source Link
user96101
user96101

I had a hard drive that couldn't mount on Linux Mint and to fix it I had to go to Windows and do chkdsk /f e:. chkdsk fixed the problem but it renamed every file with special characters and moved those files to a found.000 directory. So now I have to move and rename again those files as they were before. If I run a command from time to time to rename the files with special characters I could avoid that happening again.

I want to recursively rename files AND DIRECTORIES from the current directory. The newlines should be replaced for space and, the characters < > : " \ | ? * should be removed or better yet substituted for similar characters which aren't reserved and the spacesspaces at the start and endstart and end of a filename should be removed. Here is an example of what I want:

rename(' Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Fîlenämè $@')

Here is what would be even better:

rename(' Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Filename $@')

According to this answer it should be something like this:

LC_ALL=C find . -depth -execdir rename -n 's/[\r\n]+/ /g; s/:/./g; s/[\|]/-/g; s/[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

I need to ignore the ..Trash-1000 directory as this command is giving me input/output ERRORS and the command stops working. Having a script that handles those errors in case there are files in that directory that can be renamed would be perfect.

I was told to prune the ..Trash-1000 directory as in this answer. I also took a look at this one. But doing this is not working:

LC_ALL=C find . -depth -path ./..Trash-1000 -prune -o -print -execdir rename -n 's/[\r\n]+/ /g; s/:/./g; s/[\|]/-/g; s/[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

And it's still not deleting spaces at the start and end of the filenames.

I had to rewrite my question as the question Script to recursively replace invalid characters in filenames, not directories, with rename didn't answer mine.

I had a hard drive that couldn't mount on Linux Mint and to fix it I had to go to Windows and do chkdsk /f e:. chkdsk fixed the problem but it renamed every file with special characters and moved those files to a found.000 directory. So now I have to move and rename again those files as they were before. If I run a command from time to time to rename the files with special characters I could avoid that happening again.

I want to recursively rename files AND DIRECTORIES from the current directory. The newlines should be replaced for space and the characters < > : " \ | ? * and the spaces at the start and end of a filename should be removed. Here is an example of what I want:

rename(' Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Fîlenämè $@')

Here is what would be even better:

rename(' Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Filename $@')

According to this answer it should be something like this:

LC_ALL=C find . -depth -execdir rename -n 's/[\r\n]+/ /g; s/:/./g; s/[\|]/-/g; s/[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

I need to ignore the ..Trash-1000 directory as this command is giving me input/output ERRORS and the command stops working. Having a script that handles those errors in case there are files in that directory that can be renamed would be perfect.

I was told to prune the ..Trash-1000 directory as in this answer. I also took a look at this one. But doing this is not working:

LC_ALL=C find . -depth -path ./..Trash-1000 -prune -o -print -execdir rename -n 's/[\r\n]+/ /g; s/:/./g; s/[\|]/-/g; s/[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

And it's still not deleting spaces at the start and end of the filenames.

I had to rewrite my question as the question Script to recursively replace invalid characters in filenames, not directories, with rename didn't answer mine.

I had a hard drive that couldn't mount on Linux Mint and to fix it I had to go to Windows and do chkdsk /f e:. chkdsk fixed the problem but it renamed every file with special characters and moved those files to a found.000 directory. So now I have to move and rename again those files as they were before. If I run a command from time to time to rename the files with special characters I could avoid that happening again.

I want to recursively rename files AND DIRECTORIES from the current directory. The newlines should be replaced for space, the characters < > : " \ | ? * should be removed or better yet substituted for similar characters which aren't reserved and the spaces at the start and end of a filename should be removed. Here is an example of what I want:

rename(' Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Fîlenämè $@')

Here is what would be even better:

rename(' Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Filename $@')

According to this answer it should be something like this:

LC_ALL=C find . -depth -execdir rename -n 's/[\r\n]+/ /g; s/:/./g; s/[\|]/-/g; s/[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

I need to ignore the ..Trash-1000 directory as this command is giving me input/output ERRORS and the command stops working. Having a script that handles those errors in case there are files in that directory that can be renamed would be perfect.

I was told to prune the ..Trash-1000 directory as in this answer. I also took a look at this one. But doing this is not working:

LC_ALL=C find . -depth -path ./..Trash-1000 -prune -o -print -execdir rename -n 's/[\r\n]+/ /g; s/:/./g; s/[\|]/-/g; s/[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

And it's still not deleting spaces at the start and end of the filenames.

I had to rewrite my question as the question Script to recursively replace invalid characters in filenames, not directories, with rename didn't answer mine.

added 14 characters in body
Source Link
user96101
user96101

I had a hard drive that couldn't mount on Linux Mint and to fix it I had to go to Windows and do chkdsk /f e:. chkdsk fixed the problem but it renamed every file with special characters and moved those files to a found.000 directory. So now I have to move and rename again those files as they were before. If I run a command from time to time to rename the files with special characters I could avoid that happening again.

I want to recursively rename files AND DIRECTORIES from the current directory. The newlines should be replaced for space and the characters < > : " \ | ? * and the spaces at the start and end of a filename should be removed. Here is an example of what I want:

rename(' Fîlenämè$@<>Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Fîlenämè$@''Fîlenämè $@')

Here is what would be even better:

rename(' Fîlenämè$@<>Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Filename$@''Filename $@')

According to this answer it should be something like this:

LC_ALL=C find . -depth -execdir rename -n 's/[\r\n]+/ /g; s/[<>:\|]/./g; s/[\|]/-/g; s/["[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

I need to ignore the ..Trash-1000 directory as this command is giving me input/output ERRORS and the command stops working. Having a script that handles those errors in case there are files in that directory that can be renamed would be perfect.

I was told to prune the ..Trash-1000 directory as in this answer. I also took a look at this one. But doing this is not working:

LC_ALL=C find . -depth -path ./..Trash-1000 -prune -o -print -execdir rename -n 's/[\r\n]+/ /g; s/[<>:\|]/./g; s/[\|]/-/g; s/["[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

And it's still not deleting spaces at the start and end of the filenames.

I had to rewrite my question as the question Script to recursively replace invalid characters in filenames, not directories, with rename didn't answer mine.

I had a hard drive that couldn't mount on Linux Mint and to fix it I had to go to Windows and do chkdsk /f e:. chkdsk fixed the problem but it renamed every file with special characters and moved those files to a found.000 directory. So now I have to move and rename again those files as they were before. If I run a command from time to time to rename the files with special characters I could avoid that happening again.

I want to recursively rename files AND DIRECTORIES from the current directory. The newlines should be replaced for space and the characters < > : " \ | ? * and the spaces at the start and end of a filename should be removed. Here is an example of what I want:

rename(' Fîlenämè$@<>:"\|?* \n ', 'Fîlenämè$@')

Here is what would be even better:

rename(' Fîlenämè$@<>:"\|?* \n ', 'Filename$@')

According to this answer it should be something like this:

LC_ALL=C find . -depth -execdir rename -n 's/[\r\n]+/ /g; s/[<>:\|]/-/g; s/["?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

I need to ignore the ..Trash-1000 directory as this command is giving me input/output ERRORS and the command stops working. Having a script that handles those errors in case there are files in that directory that can be renamed would be perfect.

I was told to prune the ..Trash-1000 directory as in this answer. I also took a look at this one. But doing this is not working:

LC_ALL=C find . -depth -path ./..Trash-1000 -prune -o -print -execdir rename -n 's/[\r\n]+/ /g; s/[<>:\|]/-/g; s/["?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

And it's still not deleting spaces at the start and end of the filenames.

I had to rewrite my question as the question Script to recursively replace invalid characters in filenames, not directories, with rename didn't answer mine.

I had a hard drive that couldn't mount on Linux Mint and to fix it I had to go to Windows and do chkdsk /f e:. chkdsk fixed the problem but it renamed every file with special characters and moved those files to a found.000 directory. So now I have to move and rename again those files as they were before. If I run a command from time to time to rename the files with special characters I could avoid that happening again.

I want to recursively rename files AND DIRECTORIES from the current directory. The newlines should be replaced for space and the characters < > : " \ | ? * and the spaces at the start and end of a filename should be removed. Here is an example of what I want:

rename(' Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Fîlenämè $@')

Here is what would be even better:

rename(' Fîlenämè\n\r\n$@<>:"\|?* \n ', 'Filename $@')

According to this answer it should be something like this:

LC_ALL=C find . -depth -execdir rename -n 's/[\r\n]+/ /g; s/:/./g; s/[\|]/-/g; s/[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

I need to ignore the ..Trash-1000 directory as this command is giving me input/output ERRORS and the command stops working. Having a script that handles those errors in case there are files in that directory that can be renamed would be perfect.

I was told to prune the ..Trash-1000 directory as in this answer. I also took a look at this one. But doing this is not working:

LC_ALL=C find . -depth -path ./..Trash-1000 -prune -o -print -execdir rename -n 's/[\r\n]+/ /g; s/:/./g; s/[\|]/-/g; s/[<>"?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

And it's still not deleting spaces at the start and end of the filenames.

I had to rewrite my question as the question Script to recursively replace invalid characters in filenames, not directories, with rename didn't answer mine.

added 115 characters in body
Source Link
user96101
user96101

I had a hard drive that couldn't mount on Linux Mint and to fix it I had to go to Windows and do chkdsk /f e:. chkdsk fixed the problem but it renamed every file with special characters and moved those files to a found.000 directory. So now I have to move and rename again those files as they were before. If I run a command from time to time to rename the files with special characters I could avoid that happening again.

I want to recursively rename files AND DIRECTORIES from the current directory. The newlines should be replaced for space and the characters < > : " \ | ? * and the spaces at the start and end of a filename should be removed. Here is an example of what I want:

rename(' Fîlenämè$@<>:"\|?* \n ', 'Fîlenämè$@')

Here is what would be even better:

rename(' Fîlenämè$@<>:"\|?* \n ', 'Filename$@')

According to this answer it should be something like this:

LC_ALL=C find . -depth -execdir rename -n 's/[[\r\n]+/ /g; s/[<>:<>"\\|\|]/-/g; s/["?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

I need to ignore the ..Trash-1000 directory as this command is giving me input/output ERRORS and the command stops working. Having a script that handles those errors in case there are files in that directory that can be renamed would be perfect.

I was told to prune the ..Trash-1000 directory as in this answer. I also took a look at this one. But doing this is not working:

`LC_ALL=CLC_ALL=C find . -depth -path ./..Trash-1000 -prune -o -name '*[!a-zA-Z0-9 ._-]*'print -execdir rename -n 's/[^a-zA-Z0-9[\r\n]+/ ._/g; s/[<>:\|]/-]/g; s/["?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +`+

And it's still not deleting spaces at the start and end of the filenames.

I had to rewrite my question as the question Script to recursively replace invalid characters in filenames, not directories, with rename didn't answer mine.

I had a hard drive that couldn't mount on Linux Mint and to fix it I had to go to Windows and do chkdsk /f e:. chkdsk fixed the problem but it renamed every file with special characters and moved those files to a found.000 directory. So now I have to move and rename again those files as they were before. If I run a command from time to time to rename the files with special characters I could avoid that happening again.

I want to recursively rename files AND DIRECTORIES from the current directory. The newlines should be replaced for space and the characters < > : " \ | ? * and the spaces at the start and end of a filename should be removed. Here is an example of what I want:

rename(' Fîlenämè$@<>:"\|?* \n ', 'Fîlenämè$@')

Here is what would be even better:

rename(' Fîlenämè$@<>:"\|?* \n ', 'Filename$@')

According to this answer it should be something like this:

LC_ALL=C find . -depth -execdir rename -n 's/[:<>"\\|?*]//g' {} +

I need to ignore the ..Trash-1000 directory as this command is giving me input/output ERRORS and the command stops working. Having a script that handles those errors in case there are files in that directory that can be renamed would be perfect.

I was told to prune the ..Trash-1000 directory as in this answer. I also took a look at this one. But doing this is not working:

`LC_ALL=C find . -depth -path ./..Trash-1000 -prune -o -name '*[!a-zA-Z0-9 ._-]*' -execdir rename -n 's/[^a-zA-Z0-9 ._-]//g' {} +`

And it's still not deleting spaces at the start and end of the filenames.

I had to rewrite my question as the question Script to recursively replace invalid characters in filenames, not directories, with rename didn't answer mine.

I had a hard drive that couldn't mount on Linux Mint and to fix it I had to go to Windows and do chkdsk /f e:. chkdsk fixed the problem but it renamed every file with special characters and moved those files to a found.000 directory. So now I have to move and rename again those files as they were before. If I run a command from time to time to rename the files with special characters I could avoid that happening again.

I want to recursively rename files AND DIRECTORIES from the current directory. The newlines should be replaced for space and the characters < > : " \ | ? * and the spaces at the start and end of a filename should be removed. Here is an example of what I want:

rename(' Fîlenämè$@<>:"\|?* \n ', 'Fîlenämè$@')

Here is what would be even better:

rename(' Fîlenämè$@<>:"\|?* \n ', 'Filename$@')

According to this answer it should be something like this:

LC_ALL=C find . -depth -execdir rename -n 's/[\r\n]+/ /g; s/[<>:\|]/-/g; s/["?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

I need to ignore the ..Trash-1000 directory as this command is giving me input/output ERRORS and the command stops working. Having a script that handles those errors in case there are files in that directory that can be renamed would be perfect.

I was told to prune the ..Trash-1000 directory as in this answer. I also took a look at this one. But doing this is not working:

LC_ALL=C find . -depth -path ./..Trash-1000 -prune -o -print -execdir rename -n 's/[\r\n]+/ /g; s/[<>:\|]/-/g; s/["?*]//g; s/[ \f\t\v]+$//g; s/^[ \f\t\v]+//g' {} +

And it's still not deleting spaces at the start and end of the filenames.

I had to rewrite my question as the question Script to recursively replace invalid characters in filenames, not directories, with rename didn't answer mine.

added 324 characters in body
Source Link
user96101
user96101
Loading
added 324 characters in body
Source Link
user96101
user96101
Loading
added 7 characters in body
Source Link
user96101
user96101
Loading
added 7 characters in body
Source Link
user96101
user96101
Loading
Source Link
user96101
user96101
Loading