Spaces in filenames

Talk about Keka
Forum rules
Talk about Keka here. For bugs go to Issues.
aangel
Keka & Me
Keka & Me
Posts: 3
Joined: Sun Sep 10, 2017 6:10 pm

Spaces in filenames

Postby aangel » Sun Sep 10, 2017 6:34 pm

I use Keka as the front end but also am setting up a regular backup of a folder on my iCloud drive via the cli.

I want this is a script so that it's more legible and I can parameterize it later. The beginning of script so far is:

Code: Select all

SOURCE_DIR=~/Library/Mobile\ Documents/com~apple~CloudDocs/Course/*
DEST_ARCHIVE=/Volumes/Pleiades/CourseBackups/Test.7z 
echo "Backup up ${SOURCE_DIR} to ${DEST_ARCHIVE}./n"
/Applications/Keka.app/Contents/Resources/keka7z a ${DEST_ARCHIVE} -r "${SOURCE_DIR}"

The problem is that kaka7z is tripping over the source directory because of the space. It tries to back up "~/Library/Mobile" instead of the full path. I have no choice about that space because that is where the iCloud drive is located on macOS. I have tried quotation marks everywhere that I can think of and nothing works.

Using the command line directly works just fine:

Code: Select all

/Applications/Keka.app/Contents/Resources/keka7z a ${DEST_ARCHIVE} -r "~/Library/Mobile\ Documents/com~apple~CloudDocs//*"

Regarding the script, what does work is if I make a soft link then use that instead in the command:

Code: Select all

ln -s ~/Library/Mobile\ Documents/com~apple~CloudDocs/Course Course


The result is a link called "Course" and setting SOURCE_DIR=Course works swimmingly.

It's certainly workable but perhaps someone knows how to get this original path with the the space to work in the script. Any ideas?

User avatar
aone
Mr. Keka
Mr. Keka
Posts: 179
Joined: Sun Feb 26, 2012 8:42 pm
Contact:

Re: Spaces in filenames

Postby aone » Sun Sep 10, 2017 7:53 pm

Your code is working for me... I've tried with another path with spaces because "~/Library/Mobile\ Documents" does not exists in my environment.

Code: Select all

#! /bin/bash
SOURCE_DIR=~/VirtualBox\ VMs/Test/
DEST_ARCHIVE=~/Desktop/Test.7z 
echo "Backup up ${SOURCE_DIR} to ${DEST_ARCHIVE}./n"
/Applications/Keka.app/Contents/Resources/keka7z a ${DEST_ARCHIVE} "${SOURCE_DIR}"


Just curious, why the -r flag?
aone ~

aangel
Keka & Me
Keka & Me
Posts: 3
Joined: Sun Sep 10, 2017 6:10 pm

Re: Spaces in filenames

Postby aangel » Sun Sep 10, 2017 7:56 pm

Hmmm....not sure what to try next if it's working for you.

I'm unfamiliar with 7z and I added the -r switch thinking it was needed to recurse through the directories. Looking back, it might have been the space in the path that was causing 7z to fail and not the lack of the -r switch if the default behavior of 7z is to recurse.

User avatar
aone
Mr. Keka
Mr. Keka
Posts: 179
Joined: Sun Feb 26, 2012 8:42 pm
Contact:

Re: Spaces in filenames

Postby aone » Sun Sep 10, 2017 8:06 pm

If it's ok for you, try with full path and quotes, so no need to scape the folder space:

Code: Select all

#! /bin/bash
SOURCE_DIR="/Users/aone/VirtualBox VMs/Test/"
DEST_ARCHIVE="/Users/aone/Desktop/Test.7z"
echo "Backup up ${SOURCE_DIR} to ${DEST_ARCHIVE}.\n"
/Applications/Keka.app/Contents/Resources/keka7z a ${DEST_ARCHIVE} "${SOURCE_DIR}"


Maybe this other way works for you...
aone ~

aangel
Keka & Me
Keka & Me
Posts: 3
Joined: Sun Sep 10, 2017 6:10 pm

Re: Spaces in filenames

Postby aangel » Sun Sep 10, 2017 9:03 pm

This is now working for me, thank you! Changed a few other lines, too:

Code: Select all

printf "Source: ${SOURCE_DIR}\nDestination: ${DEST_ARCHIVE}.\n"
/Applications/Keka.app/Contents/Resources/keka7z a ${DEST_ARCHIVE} -x!.DS_Store "${SOURCE_DIR}"

User avatar
aone
Mr. Keka
Mr. Keka
Posts: 179
Joined: Sun Feb 26, 2012 8:42 pm
Contact:

Re: Spaces in filenames

Postby aone » Sun Sep 10, 2017 9:44 pm

Glad to help :)
aone ~


Return to “Chat”

Who is online

Users browsing this forum: No registered users and 1 guest