Python Forum
concatenat - shutil - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: concatenat - shutil (/thread-32461.html)



concatenat - shutil - jmabrito - Feb-10-2021

import shutil
t1 = 'bjjj'
t2 = 4455
t3 = '.txt'
t6 = print(t1+str(t2)+t3)
shutil.copy('bjjj.txt', 't6')
shutil.copy('bjjj.txt', 'bjjj4455.txt')

NOTE NOTE
I have a job file called bjjj.txt. When the program ended, I wanted it to be copied to the same name concatenated with a variable. I made immense attempts to no avail. If you put fixed bjjj4455.txt it works perfectly. But I want to increase the number 4455 +1 ...
Thank you


RE: concatenat - shutil - BashBedlam - Feb-10-2021

Is this what your are looking for?

prefix = 'bjjj'
version_number = 4455
version_number += 1
sufix = '.txt'
new_file_name = f'{prefix}{version_number}{sufix}'
shutil.copy('bjjj.txt', new_file_name)
or condensed:

new_file_name = f'bjjj{version_number}.txt'



RE: concatenat - shutil - jmabrito - Feb-11-2021

Smile Smile Smile Smile Smile Smile Smile Heart
thank you. what should I do to complete this request of mine. Worked perfectly. thanks again


RE: concatenat - shutil - jmabrito - Feb-11-2021

(Feb-10-2021, 11:21 PM)BashBedlam Wrote: Is this what your are looking for?

prefix = 'bjjj'
version_number = 4455
version_number += 1
sufix = '.txt'
new_file_name = f'{prefix}{version_number}{sufix}'
shutil.copy('bjjj.txt', new_file_name)
or condensed:

new_file_name = f'bjjj{version_number}.txt'
NOTE NOITE
100% sorted out Dance LOL

I have a problem to finalize the program for the post subject "goto". there is a line in the "for _ in range (1)" cycle that says
"print (f '{k} EXISTS')" must go back to for _, as this number that exists should not be announced. please, can you help me?! In the hands of a good programmer, it should be easy. Do you have access to my GOTO order?