B4J Question Batch rename file?

tsteward

Well-Known Member
Licensed User
Longtime User
I have downloaded digital files from my opencart server and they all have random extensions.
I need to be able to
  • Chooser a directory.
  • Lists all files in that directory.
  • Renames each file by removing anything after .pdf (keeping the .pdf extension only).

Can anyone help with this. I had a go and it sounds simple but I failed :eek:

Hoping someone would be kind enough to knock up a quickie for me PLEASE!
 

Sandman

Expert
Licensed User
Longtime User
In case this was a one-off, and you have access to Linux:

To delete everything after "pdf" in a file name in Linux, you can use the rename command with a regular expression. For example, the command...
Bash:
rename 's/(.*\.pdf).*/$1/' *.pdf
...will rename all PDF files by keeping only the part before any additional characters after "pdf".
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
In case this was a one-off, and you have access to Linux:

To delete everything after "pdf" in a file name in Linux, you can use the rename command with a regular expression. For example, the command...
Bash:
rename 's/(.*\.pdf).*/$1/' *.pdf
...will rename all PDF files by keeping only the part before any additional characters after "pdf".
That's cool, but in windows?
 
Upvote 0
Top