I apologize if this has been answered already I have searched through the forums for an answer with no luck.
I am designing a webpage to remote control media monkey i want the fan art from a pre-selected folder to display on the background image. currently i have set up a folder I also have the script to copy the fanart from the music artist folder. My problem is when i get the artist information from media monkey i try to add it to the path inside python and i get an error. My question is how do i add a variable to a path name inside a python script.
import os
import shutil
dir_src = "c:\\Music\\(eg.globals.artist)\\fanart.jpg"
dir_dst = "c;\\fanart"
for file in os.listdir(dir_src):
print file # testing
src_file = os.path.join(dir_src, file)
dst_file = os.path.join(dir_dst, file)
shutil.move(src_file, dst_file)
The error is stating there is no such file named "c:\\Music\\(eg.globals.artist)\\fanart.jpg"
Thanks
Douglas
Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Use variable in file name python script
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Use variable in file name python script
I would try:
Code: Select all
dir_src = "c:\\Music\\" + str(eg.globals.artist) + "\\fanart.jpg"
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
drossmill06
- Posts: 2
- Joined: Sun Nov 20, 2011 6:57 am
Re: Use variable in file name python script
Works perfect thank you for the quick reply