Script to work with spaces in folders

Any questions? Need some help?
Post Reply
int21h
Donor
Posts: 13
Joined: 12 Aug 2013, 06:14

Script to work with spaces in folders

Post by int21h »

I know the answer is in front of me but I haven't been able to get the script to work when there is a space in the folder name.
I'm using Windows 7x64, SABNzbd and passing the UT parameters for file path.

This is my script to run post completion:

Code: Select all

SET FILE_PATH=%1
SET FILE_NAME=%3
"C:/Program Files/FileBot/filebot.exe" -script fn:amc --output "M:/" --log-file amc.log --action move --conflict override -non-strict --def music=n artwork=y --def deleteAfterExtract=y --def clean=y --def ut_dir="%FILE_PATH%" --def ut_title="%FILE_NAME%" ut_kind=multi 
This is the error log:

Code: Select all

           Locking C:\Users\User\AppData\Roaming\FileBot\logs\amc.log
Parameter: music = n
Parameter: artwork = y
Parameter: deleteAfterExtract = y
Parameter: clean = y
Parameter: ut_dir = F:\Downloads\SABNzbd\Game
Parameter: ut_title = Game
Argument: C:\Program Files (x86)\SABnzbd2\Of
Argument: C:\Program Files (x86)\SABnzbd2\Thrones
Argument: C:\Program Files (x86)\SABnzbd2\S05E02
Argument: C:\Program Files (x86)\SABnzbd2\Proper
Argument: C:\Program Files (x86)\SABnzbd2\720p
Argument: C:\Program Files (x86)\SABnzbd2\HDTV
Argument: C:\Program Files (x86)\SABnzbd2\x264-BATV
Argument: C:\Program Files (x86)\SABnzbd2\Of
Argument: C:\Program Files (x86)\SABnzbd2\Thrones
Argument: C:\Program Files (x86)\SABnzbd2\S05E02
Argument: C:\Program Files (x86)\SABnzbd2\Proper
Argument: C:\Program Files (x86)\SABnzbd2\720p
Argument: C:\Program Files (x86)\SABnzbd2\HDTV
Argument: C:\Program Files (x86)\SABnzbd2\x264-BATV
Argument: C:\Program Files (x86)\SABnzbd2\ut_kind=multi
File not found: C:\Program Files (x86)\SABnzbd2\Of
Failure (~~_~~)
User avatar
rednoah
The Source
Posts: 23950
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Script to work with spaces in folders

Post by rednoah »

I will not fix your broken cmdline call for you.
You're not quoting arguments correctly. Use Google or read the manual I wrote specifically for CLI beginners.

@see viewtopic.php?f=4&t=1899
:idea: Please read the FAQ and How to Request Help.
int21h
Donor
Posts: 13
Joined: 12 Aug 2013, 06:14

Re: Script to work with spaces in folders

Post by int21h »

Yep, you're right.. my bad!
coolwaterblue
Donor
Posts: 3
Joined: 25 Oct 2015, 09:53

Re: Script to work with spaces in folders

Post by coolwaterblue »

Can someone please fix the command in this script so I can use it :)

I have just donated for the support and will continue to do so!

Have played around and even have my own amc offline and has worked a dream for ages but I am getting the same issue as above with the spaces in the title being passed as multiple arguments as it seems my source files now include lengthy names.

Appreciate I need to escape them somehow, but not sure exactly and am running out of patience, so if someone can just fix the above for me I'll donate for the time!!

Sorry to be an idiot :roll: , but kinda running out of time to play and have read the FAQs and the guide by Red Noah.

Current command (have tried others but will just post this to keep things simple)

Code: Select all

@ECHO OFF
SET FILE_PATH=%1
SET FILE_NAME=%3
"C:/Program Files/FileBot/filebot.launcher.exe" -script "F:/DOCUMENTS/AMC/newamc.groovy" --output "F:/" --log-file "F:/amc.log" --action copy --conflict override -non-strict -no-xattr --def music=n --def clean=y excludeList=amc.txt --def "ut_dir=%FILE_PATH%" --def "ut_title=%FILE_NAME%" ut_kind=multi 
This is the script log that gets returned:

Code: Select all

Run script [F:/DOCUMENTS/AMC/newamc.groovy] at [Mon Oct 26 19:21:14 GMT 2015]
Parameter: music = n
Parameter: clean = y
Parameter: excludeList = amc.txt
Parameter: ut_dir = F:\DOWNLOAD\South.Park.S05E13.Kenny
Parameter: ut_title = South.Park.S05E13.Kenny
Argument: C:\Program Files (x86)\SABnzbd\Dies.720p.WEB-DL.DD2.0.AVC-jhonny2
Argument: C:\Program Files (x86)\SABnzbd\Dies.720p.WEB-DL.DD2.0.AVC-jhonny2
Argument: C:\Program Files (x86)\SABnzbd\ut_kind=multi
File not found: C:\Program Files (x86)\SABnzbd\Dies.720p.WEB-DL.DD2.0.AVC-jhonny2
Failure (~~_~~)
Thanks for any help.

Oh and seeing as this is my first post, I would like to say a big thanks to everyone involved with Filebot as it is a brilliant tool.

CWB
User avatar
rednoah
The Source
Posts: 23950
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Script to work with spaces in folders

Post by rednoah »

Apparently, variables like %1 come with quotes, so you're probably double/un-quoting things at a later point.

Try this:

Code: Select all

ut_dir=%1 --def ut_title=%3
Or this:

Code: Select all

SET FILE_PATH=%~f1
SET FILE_NAME=%~3
@see http://steve-jansen.github.io/guides/wi ... ables.html
:idea: Please read the FAQ and How to Request Help.
coolwaterblue
Donor
Posts: 3
Joined: 25 Oct 2015, 09:53

Re: Script to work with spaces in folders

Post by coolwaterblue »

Thank you very much for your quick reply.

I'll give it a shot tonight and also thanks for the link - I'll try to educate myself a bit better!

I'll post the outcome so if anyone else has the issue they may find it useful.

Have a great day!!!

CWB
coolwaterblue
Donor
Posts: 3
Joined: 25 Oct 2015, 09:53

Re: Script to work with spaces in folders

Post by coolwaterblue »

Yes!!!!!!!

Thank you very much, this worked:

Code: Select all

SET FILE_PATH=%~f1
SET FILE_NAME=%~3
Keep up the good work :mrgreen:
Post Reply