I'm writing to you because I need to create a batch file that allows me to rename many files in .pdf keeping only the first 50 characters.
I've tried this:
for %i in (*.txt) do (set fName=%i)
ren %fName% %fName:~0,-11%.txt
But this removes only the last 11 characters. I've tried to modify this code but I can in no way do what I need.
I think it's a very easy thing for someone who is a little more expert than me so I ask you if you can help me.
Thanks in advance.
I insert below the errors that come to me following the corrections:
C:\Users\---\Desktop\Conversione PDFA>for %fname:~0,50% in (*.pdf) do (set fname=%~ni)
graeiojpoghnpiofsdnpibnwapobnslnsdlekpfèwekrgpjbm was unexpected at this time.
C:\Users\---\Desktop\Conversione PDFA>for %fname:~0,50% in (*.pdf) do (set fname=%~ni)
graeiojpoghnpiofsdnpibnwapobnslnsdlekpfèwekrgpjbm was unexpected at this time.
C:\Users\---\Desktop\Conversione PDFA>for %fname:~0,50% in (*.pdf) do (set fname=%i)
graeiojpoghnpiofsdnpibnwapobnslnsdlekpfèwekrgpjbm was unexpected at this time.
C:\Users\---\Desktop\Conversione PDFA>ren %fName% !fname:~0,50!.pdf
The syntax of the command is incorrect.
C:\Users\---\Desktop\Conversione PDFA>ren %fName% %!fname:~0,50!.pdf
The syntax of the command is incorrect.