1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Import data from kDrive from iCloud
This guide details how to import iCloud data using rClone on kDrive Infomaniak.
COMPATIBILITY my kSuite âś— | my kSuite+ âś— âś”= Compatible offer | âś—= Not available |
Preamble
- Since Apple does not offer an API like its competitors, a solution to retrieve documents from an iCloud Drive is to install the kDrive macOS app to synchronize the icloud folder which must be in your library. The guide below offers a solid alternative.
- kDrive supports rclone streaming upload via WebDAV, up to 50 GB (extendable to 100 GB) to avoid abuse, with automatic error handling if the limit is exceeded without prior specification of the size via
Content-Length
.
1. Configure rclone for drive access
Install rclone on your computer
There is a version of rclone with a graphical interface (GUI) but it is quite possible to do this via the command line (CLI):
- Install rclone from a
Terminal
type application on your device, by typing the entire following command:sudo -v ; curl https://rclone.org/install.sh | sudo bash
- Enter the password for your session on your computer to start the installation:
- Refer to the official installation guide if necessary.
Configure the remote disk (iCloud) on rclone
- Once rclone is installed, enter the command
rclone config
.- Refer to the official configuration guide if necessary.
- Then choose to configure a new remote import by answering
n
forNew remote
. - Name the remote disk, for example
appledrive
: - Choose the type of disk to import by responding
iclouddrive
which corresponds to iCloud Drive among the proposed choices. - Indicate to rclone the
apple_id
by entering your Apple ID (usually an email address). - Choose to use your own password linked to the Apple ID account (
y
). - Enter your password twice as requested:
- Answer “No”
n
to the question about “advanced configuration”. - A window on your device should open to warn you of a remote connection; authorize it:
- A window on your device should open with a 2FA code; copy it:
- Paste the code when <code>rclone</code> asks for it. <li>Answer “Yes” <code>y</code> to the last question if all the information presented is correct.</li> Configuration of the destination disk (kDrive) on rclone
It is possible to act directly on the configuration file of rclone by pasting your kDrive configuration in it in the form for example:
But here is how to proceed step by step as for the previous configuration:
- Still in the terminal, enter
n
for a new disk configuration and enter the namekDrive
to recognize your destination disk:
[kDrive]
type = webdav
url = https://kDrive_ID_HERE.connect.kdrive.infomaniak.com/
vendor = other
user = user@email.com
pass = PASSWORD_HERE_OR_APP_PASSWORD_IF_2FA
<li>Choose the type of disk to import by responding <code>webdav</code> which corresponds to a WebDAV configuration among the proposed choices.</li>
Enter the following information:
url
= direct access to kDrive (see this other guide about the kDrive ID for the connection URL)- <li><code>vendor</code> = rclone (option #6)</li>
user
= email address to log in to the Infomaniak user account- Answer “Yes”
y
to the password question, then enter the password:- application password in case of double authentication activated or that of your Infomaniak user account if you have not activated 2FA.
- Leave the
bearer_token
blank, then answer “No”n
to the question about “advanced configuration”.
- Answer “Yes”
y
to the last question and your 2 disks will appear:
2. Copy data from iCloud to kDrivePrerequisites
<li>Consult the available options in the <a href="https://rclone.org/iclouddrive/" target="_blank">official guide</a> before starting an import.</li>
Example of a command to start copying your iCloud data to the root of your kDrive:
This will immediately start copying your iCloud folders, subfolders, and contents to the personal folder of your Infomaniak kDrive!
Details about the dates of your exported photos
sudo rclone copy appledrive: kDrive:
If you export your photos from iCloud to Infomaniak kDrive, be careful about the date metadata. During export, the file creation dates may be modified and replaced by the export date instead of the original date of the photo.
Here is a script for advanced users that allows you to restore the correct data to your files from the EXIF information (it is recommended to process batches of 7000 photos max. to avoid a crash):
<li>Download <strong>ExifTool</strong> <a href="https://exiftool.org/index.html">https://exiftool.org/index.html</a> (macOS Package).</li>
Install the application by authorizing its opening in advance if necessary:
- Open Script Editor (located in your Applications > Utilities folder):
- Click on New document.
- Copy-paste the long script provided below into the Script Editor window.
- Click on Run to start the script, a window opens:
Select the folder to analyze.
- <li>Let the script run, it will modify the dates or write the errors in a file <code>errors.txt</code> on the desktop.</li>
The script to copy-paste entirely:
- Sélectionnez le dossier à analyser.
- Laissez ensuite le script tourner, il modifiera les dates ou écrira les erreurs dans un fichier
errors.txt
sur le bureau.
Le script à copier-coller entièrement:
-- replace file date with EXIF creation date or date from name after the first dash -
tell application "Finder"
set FolderPath to choose folder with prompt "Select the folder containing the files to update"
my processFolder(FolderPath)
end tell
on processFolder(aFolder)
tell application "Finder"
-- process files:
set fileList to files of aFolder
repeat with eachFile in fileList
-- process a single file
set theFile to eachFile
set AppleScript's text item delimiters to {""}
set fileName to name of eachFile --get the file name
set eachFile to eachFile as string --file path
set hasDate to true --initialize date found flag
try
--get date if available
set photoDate to do shell script "/usr/local/bin/exiftool -DateTimeOriginal " & quoted form of POSIX path of eachFile
if photoDate is "" then set photoDate to do shell script "/usr/local/bin/exiftool -CreationDate " & quoted form of POSIX path of eachFile
if photoDate is "" then set photoDate to do shell script "/usr/local/bin/exiftool -CreateDate " & quoted form of POSIX path of eachFile
if photoDate is "" then
set hasDate to false --check if date was found
end if
on error
set hasDate to false -- error retrieving date
set photoDate to ""
end try
if length of photoDate > 20 then
--format extracted date
set x to (length of photoDate) - 33
set OriginalDate to text -x thru -1 of photoDate
set formattedDate to text 1 thru 5 of OriginalDate
set theYear to formattedDate
set formattedDate to formattedDate & text 7 thru 8 of OriginalDate
set theMonth to text 7 thru 8 of OriginalDate
set formattedDate to formattedDate & text 10 thru 11 of OriginalDate
set theDay to text 10 thru 11 of OriginalDate
set formattedDate to formattedDate & text 13 thru 14 of OriginalDate
set theHour to text 13 thru 14 of OriginalDate
set formattedDate to formattedDate & text 16 thru 17 of OriginalDate
set theMinute to text 16 thru 17 of OriginalDate
set formattedDate to formattedDate & "." & text 19 thru 20 of OriginalDate
set theSecond to text 19 thru 20 of OriginalDate
set newName to theYear & "-" & theMonth & "-" & theDay & " " & theHour & "." & theMinute & "." & theSecond
set testValue to formattedDate as string --check if found date is 000
if testValue is " 000000000000.00" then
set hasDate to false
else
-- set file date to original EXIF date and write to log
do shell script "touch -t " & formattedDate & " " & quoted form of POSIX path of eachFile
set logFile to open for access ((path to desktop folder as text) & "Date Found.txt") as text with write permission
write "Original date found for file: " & OriginalDate & " " & eachFile & return to logFile starting at eof
close access logFile
end if
end if
if hasDate is false then
-- get date from file name after first dash
set nb to ""
set nameDate to ""
set fileName to fileName as string
set savedDelimiters to AppleScript's text item delimiters --save delimiters
set AppleScript's text item delimiters to {"-"} --split on "-"
set nb to offset of "-" in fileName
if nb is not 0 then
set AppleScript's text item delimiters to savedDelimiters --restore delimiters
set nameDate to characters (nb + 1) thru (nb + 8) of fileName as string
set nameDate to nameDate & "1200.00"
set cmd1 to "/usr/local/bin/exiftool -datetimeoriginal=" & nameDate & " " & quoted form of POSIX path of eachFile
set cmd2 to "/usr/local/bin/exiftool -createdate=" & nameDate & " " & quoted form of POSIX path of eachFile
end if
try
-- write date from name to EXIF
do shell script cmd1
do shell script cmd2
do shell script "touch -t " & nameDate & " " & quoted form of POSIX path of eachFile
do shell script "rm " & quoted form of POSIX path of (eachFile & "_original")
on error
-- if date from name is invalid, log the error
set logFile to open for access ((path to desktop folder as text) & "Date Error.txt") as text with write permission
write "No valid date found in file name: " & eachFile & return to logFile starting at eof
close access logFile
end try
end if
end repeat
-- process folders:
set folderList to folders of aFolder
repeat with eachSubfolder in folderList
-- process a subfolder
my processFolder(eachSubfolder)
end repeat
end tell
end processFolder
tell application "Finder"
display dialog "Done! All files processed." buttons {"Close"}
end tell