Renaming files (remove everything after ".pdf")

Hello,
Is there a way to rename all files of a directory (and its sub directories) by removing everything after “.pdf” ?

Example:
Before :
filename_kjhs.pdf?64687546
filesdjhsd_kdki.pdf?64687546
filesdjhsd_kdki.pdf?64687547

Desired Results :
filename_kjhs.pdf
filesdjhsd_kdki.pdf
filesdjhsd_kdki_1.pdf

It seems that I need to use the copyto command https://rclone.org/commands/rclone_moveto/ using the same thing for source and destination. But I am lost !

Thanks in advance :wink:

You can do this one at a time with

rclone moveto 'remote:path/filename_kjhs.pdf?64687546'  'remote:path/filename_kjhs.pdf'

If you’ve got lots to do then you can use rclone lsf to list the offending files

rclone lsf -R --include '*pdf?*' --files-only remote:path

And then script the renames.

You might also find it easier to use rclone mount and then use normal OS tools.

1 Like