Auto naming/saving a file to a folder
Hi there,
Can anyone point me towards any helpful info regarding Max's idiosyncracies regarding file naming and any example patches that might help with a portion of a patch for saving a file (in this case video, but I imagine audio should be exactly the same in theory) to the hard drive?
I am on Mac and ideally want to use this for saving files direct to an already plugged in USB stick.
Thanks
crabhands
[sprintf] help file and subpatches
they can explain how to build your filepath correctly (as a single symbol in quotes) and how to use [prepend write] to send the write command.
filepaths work great but you do need some fiddling the first time to understand how Max deals with them...usually the issue is that there are spaces etc. in it. [sprintf] will solve all your woes and is a great object to learn if you haven't already.
This could help:
pnyboer;
thanks for the patch, that's really helpful actually.
I seem to be unable to save my file despite following your patch, could you see if it works for you? i am getting an error from jit.vcr saying it's having a problem creating the soundtrack. audio settings are all on and correct.
(my USB stick is called "NO NAME")
additionally, could anyone clarify for me exactly what the OSX file path for the main harddrive actually is?
Thanks!
To clarify,
I have now got the file saving to work to the USB stick but it seems to crash the patch each time.
I had forgotten to specify the frame rate of the video at first.
Perhaps it'd be better to save locally and then move the file to the USB stick after the fact. Is this possible within Max?
Thanks,
USB flash drives are formatted in FAT32 format. The FAT32 file system may be causing problems. It could also have to do with the speed at which the file is being written. I like your idea of saving somewhere else and then copying the file over to the flash drive. You could use the aka.shell object to do the copying.
cp /Users/Me/Documents/MySounds/MySoundFile.aiff /Volumes/NO NAME
That command could be generated with sprintf and triggered when the write to disk is complete.
MH
Hi MHarter,
Thanks for that. I'm looking into it now and it's a little confusing as I don't know anything about unix shell commands but it seems like your post contains exactly what need to do. That said, I tried using your method and aka.shell is giving me a 'no result' error, so I'm assuming I've got the file/directory naming wrong. I've since tried getting a file that I have saved using sprintf and copying it to a different local directory to check I can get the functionality working at all.
Would you be able to tell me if this works ok for you? I'm worried I'm missing out some detail about how Max or the aka.shell objects deals with spaces or something similar:
Thanks
EDIT: I've since tried experimenting with the Jasch fscopy external which has been working fine for copying to/from different spots on the local drive but still having difficulty when looking to move files to and external drive. Do I just want to have the destination as /Volumes/HardDriveName/Folder/ or is it something else? I am on 10.6.7, Max 6 and the above format doesn't seem to work.
Can you write audio files to the thumb drive? Here's a simple test:
Hi Chris,
Writing to the drive isn't a problem with your patch at all.
Having played around with fscopy some more it seems like it might not like anything that isn't on the local drive.
I can copy within my local drive starting the file path as /User/etc but not if I start it with Macintosh HD/User/etc which is what how I'm writing to the disk with Max using sprintf and jit.vcr.
I'm now going to try creating an alias for the external drive on my desktop to try trick fscopy into letting me save onto an external drive, though im not sure if that'll work.
*Does anyone know how OSX Automator works in case that works because I'd want to be able to automagically make an Alias for a drive as soon as it's plugged in. I'm just assuming it can do that, I have no idea.
*Alternatively I guess I'll keep playing with aka.shell but if anyone else has any suggestions for externals for copying files to an external drive that'd be great!
I'm _not_ a jitter guy, but I think that this may be more of a jit.vcr bug than a write destination problem. I get the "error creating a soundtrack for movie" movie no matter where I'm trying to write the file. I get this message from the jit.vcr help file, too.
It turns out that path names get mangled when passed through some Max objects, so aka.shell will not get the proper path. There are ways around this, but they would be more complicated than using fscopy.
MH
OK, I went after it some more and got aka.shell to do the file copy. I used the combine object instead of sprintf to construct the unix shell command, either should work though. the shell either wants file paths to have quotes or have escaped characters, but the combine and sprintf objects strip the quotes off (and add quotes around the whole command). The message and textedit objects discard backslashes, so escaped characters aren't escaped any more.
Lucky for us, the cp command in unix doesn't mind single quotes instead of double quotes, and Max doesn't mess with those, so we win with that strategy!
One thing to watch for though, don't put the single quote before ~/ (your home directory) or it will be taken literally.
Here is the format: cp -v ~/'Documents/My folder that has the sound in it/The name of my sound.aif' '/Volumes/My USB stick/'
the -v is a verbose flag, it tells the shell to send a message back when the copy is done.
All that gets double quotes around it when it goes to aka.shell, it has to be a symbol.
My patch makes a file name from an integer called "Sound 1" (whatever the integer is), but you can change that pretty easily. You will get a beachball while copying, maybe deferlow will help with that.
Hi, thanks for your comprehensive investigating and answer! I tried just putting in my location details as below but I'm still getting aka.shell: no result and the file is not copying. As far as I can tell I haven't done anything odd to the formatting of the disk locations.
The final message sent to aka.shell is "cp -v ~/'Users/alexgodoy/Documents/VIDEO/Sound 1.aif' '/Volumes/USB DISK/'"
Any ideas....???
Thanks again!
I think that the source path is incorrect. I don't think that you want the ~/ before Users, I think you want it to start with /Users
As an aside, this sort of path string manipulation is complicated by spaces in disk, file or directory names. I make a habit of not using spaces or other special characters in my disk/file/folder names.
It worked perfectly as soon as I removed the ~/ thanks Chris!!
"cp -v ~/'Documents/VIDEO/Sound 1.aif' '/Volumes/USB DISK/'"
You don't need the Users/alexgodoy/ part because ~/ represents the root folder of the currently active user account. In your case that would be /Users/alexgodoy/
So, the way you had it, it would try to find a folder in /Users/alexgodoy/Users/alexgodoy/Documents/VIDEO/
The nice thing about ~/ is that it will allow your patch to work even if a different user is running it.
It certainly is hairy stuff, but when it works, it sure feels good!
MH
Thank you very very much for clarifying!