I'd like to write a python script which renames a file on my desktop to a number which is 1 less than what it was before. If you're wondering, the number tells me how many days left 'till I finish high school, lol, but I've also got other things inside the file.
I'm still learning python (reading 'Learning Python') but I've been able to figure some of the commands I'll be using in this script.
import os os.rename('C:/Users/Sam/Desktop/oldname.txt', 'C:/Users/Sam/Desktop/rename.txt')
But what I want to do is take the file I have on my desktop ('516.txt' as of today) and have a command that does something like 'filename -= 1'.
The problem is, I don't know how to attach the number in the filename to a variable. These commands might not exits (since I don't know too much syntax) but I want something like:
x = numbers in filename.txt
x -= 1
How might I go about doing this?