Welcome, Guest
Python Scripts for ComicRack

TOPIC: Paths

Paths 6 years 9 months ago #11462

  • mizio66
  • mizio66's Avatar
  • Offline
  • Platinum Boarder
  • Started reading comics at 4... and still counting!
  • Posts: 451
  • Thank you received: 143
  • Karma: 67
Ok, now that i got into scripting, I'm addicted. Though the limitation of Comicrack's Python (am I right ? there are limitations, right?) makes some task harder..

I have this script that copies comics from one folder to another, renaming them. Then it should write the new path to a file, using "\\" and not "\" as in Windows (don't ask me YET why).

so, I have as a result:
What i Have in the script: filename.0=V:\Public\Fumetti\Diabolik\Diabolik - T196308 - Sepolto vivo!.cbz

What I need: filename.0=V\:\\Public\\Fumetti\\Diabolik\\Diabolik - T196308 - Sepolto vivo\!.cbz (note also the \! thingy).

Cannot use os.normpath (can't, can i ?), so was wondering if anybody out there ever faced the same problem... and solved it...:woohoo:

thanks !
The administrator has disabled public write access.

Re: Paths 6 years 9 months ago #11463

  • forkicks
  • forkicks's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 869
  • Thank you received: 108
  • Karma: 37
mizio66 wrote:
I have this script that copies comics from one folder to another, renaming them. Then it should write the new path to a file, using "\\" and not "\" as in Windows (don't ask me YET why).

"\" is the escape character, which in windows also means directory separator. As such, and to avoid confusion with escaping characters into strings, windows requires you to double \\ to mean a single "\" in directory paths, while writing code. Im not sure about python, but in c#, you can overcome that by adding a "@" before the string, as such:

@"c:\Program Files\comicrack\"
is exactly the same directory-wise as:
"c:\\Program Files\\comicrack\\"

mizio66 wrote:
so, I have as a result:
What i Have in the script: filename.0=V:\Public\Fumetti\Diabolik\Diabolik - T196308 - Sepolto vivo!.cbz

What I need: filename.0=V\:\\Public\\Fumetti\\Diabolik\\Diabolik - T196308 - Sepolto vivo\!.cbz (note also the \! thingy).

You're hitting all the right spots. "!" also needs to be escaped.
mizio66 wrote:
Cannot use os.normpath (can't, can i ?), so was wondering if anybody out there ever faced the same problem... and solved it...:woohoo:

thanks !

Haven't touched python properly yet, but other have, and im sure they'll throw some feedback.

[Edit: As an after-thought. Have you taken a look at the Organize Files and Folders script? It also moves files around, so there may be something to help you there]

fK
Last Edit: 6 years 9 months ago by forkicks.
The administrator has disabled public write access.

Re: Paths 6 years 9 months ago #11465

  • mizio66
  • mizio66's Avatar
  • Offline
  • Platinum Boarder
  • Started reading comics at 4... and still counting!
  • Posts: 451
  • Thank you received: 143
  • Karma: 67
Forkicks, excellent tip indeed. Since I don't use that script is one of those i didn't browse for tips... and in there there is one of the most important tips ever... os.py !!!

Thanks to you andto the author of that...

:-)
The administrator has disabled public write access.
Time to create page: 0.169 seconds

Who's Online

We have 155 guests and 7 members online