* * *

Author Topic: Copy mp3 files from nas to usb  (Read 960 times)

gambothell

  • New member
  • *
  • Posts: 27
Copy mp3 files from nas to usb
« on: March 16, 2017, 03:28:04 pm »
I have tried using fileutil copyfile to copy mp3 files stored on my nas to a usb drive. I get no errors, but the files do not copy. I tried using a TProcess to issue a cp command. Again, I get no errors, but the mp3 files are not copied. I have several mp3 players and I have written a synchronization program to keep them current with my nas music folder. Is this a permissions issue? I have no problem connecting to the nas or the mp3 player and can easily scan both directories. I have also tried using TProcess with elevated privileges with same results.
Any suggestions  :o

Leledumbo

  • Hero Member
  • *****
  • Posts: 7685
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Copy mp3 files from nas to usb
« Reply #1 on: March 17, 2017, 10:16:33 am »
Try displaying the output of SysErrorMessage(GetLastOSError) after CopyFile returns false.

gambothell

  • New member
  • *
  • Posts: 27
Re: Copy mp3 files from nas to usb
« Reply #2 on: March 18, 2017, 03:51:10 pm »
Thanks for the feedback. I will do that and report.

Bart

  • Hero Member
  • *****
  • Posts: 2723
    • Bart en Mariska's Webstek
Re: Copy mp3 files from nas to usb
« Reply #3 on: March 18, 2017, 04:43:37 pm »
You can use my FileCopy() from myfileutils.pp unit. It has a callback event to show progress of the copying.
If you feel paranoid like me, then define debug_paranoid. This will tell you what went OK and what wrong (your program needs to have a console if you define debug_paranoid).

Bart

gambothell

  • New member
  • *
  • Posts: 27
Re: Copy mp3 files from nas to usb
« Reply #4 on: March 19, 2017, 09:28:12 pm »
Thank you Bart, I will add that to my program. I did find my problem, it was a corrupted directory on the mp3 player.

gambothell

  • New member
  • *
  • Posts: 27
[Solved] Copy mp3 files from nas to usb
« Reply #5 on: March 25, 2017, 10:10:18 pm »
 ;) Finally, I have solved this. I am using Linux Mint 18.1 and Ubuntu 16.04, Lazarus 1.6 and FPC 3.0.0

Issue: Could not copy mp3 files from my NAS storage to my MP3 player or Android 5.1 Tablet, SD card using CopyFile or using cp in TProcess. I could create a folder on the mp3 drive for the artist and the album folder in it, but the individual mp3 files and folder.jpg files would not transfer. I even tried elevated privileges to no avail.

Problem: When you attach a MP3 player or Android tablet to a USB drive, it gets mounted in: /run/user/1000/gvfs and is mounted using the mtp file system. Unfortunately, mtpfs mounts the drive as read only. That is what has caused my problem.

If you install mtp-tools (not required) and in terminal type mtp-detect, you get several pages giving you the details of your mtp mount. Note: if you run this, the mp3 player must be connected to a usb port, but not mounted. Reading through the info, it clearly tells you that the drive is read only.

Solution: You have to use gvfs-copy instead of CopyFile. You need to do this in a TProcess with the CommandLine = gvfs-copy 'source path/filename' 'destination path/filename'
Note: The source and destination must be enclosed with a single quote.

I found you cannot copy directly from the NAS to the mtp:host.... My NAS also mounts in /run/user/1000/gvfs and uses apt (Linux Mint) or smb (Ubuntu 16.04 Virtualbox). What worked for me was to copy the Artist folder containing the Album folders to a temp folder on my desktop, then using the gvfs-copy from the local temp folder to the mtp:host disk. You cannot copy recursivly, so you have to copy each mp3 file individually.

reference: http://unix.stackexchange.com/questions/193132/unable-to-perform-file-operations-on-a-mtp-device-mounted-via-gvfs-operation-n
               https://wiki.debian.org/mtp





 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus