Mac OS X File / Folder Management: When to Copy instead of Move - cocoa

The Finder uses some kind of rules to determine if an Item can be moved or will be copied. After dragging an Item, in certain cases Finder shows a drag-copy-cursor. Are these rules in an API available? Checked with Spotlight-Metadata, NSURL and NSFileManager: no result.
Here's what i came up with:
if a Folder contains a ".localized" File: the folder is copied
if a Folder is listed anywhere in a NSSearchPathDirectory
Is my assumption right? or has it to do with NSURLIsSystemImmutableKey or NSURLIsUserImmutableKey which i thought is the "Locked" flag?
Furthermore depending on various other Metadata like write-permissions and locked-flag:
ON SOURCE:
moving a readonly file: move is possible
moving a readonly folder needs login from an admin
moving a locked file creates a copy
moving a locked folder creates a copy
moving a folder with a locked file inside: move is possible
moving a selection with both locked and unlocked items creates a copy
moving a dropbox writeonly folder: move is possible
writeonly files do not exist in Finder
moving a file without any permissions: move is possible (as the move rights depend on the enclosing folder)
moving a folder with a file without any permission: move is possible (as long its a move, for copy it asks for login)
if a Folder contains a ".localized" File: the folder is copied
if a Folder is listed anywhere in a NSSearchPathDirectory (home directory, ...) it is copied
if a folder contains another book: move is possible
ON TARGET:
moving an item into a dropbox creates a copy
moving an item into a locked folder: not possible
moving an item into a read-only folder: asks for login

*) Regarding the Finder: if a file or directory is being dragged from one volume to another, it will (by default) be copied. If the action is being performed on the same volume the file or folder will (by default) be moved. As a side note to file operations on volumes: 'moving' things across different filesystemes behaves differently, again. Normally, moving a file or directory doesn't mean 'copying' and 'deleting' the original afterwards - only their links within the filesystem usually become modified but here and then, it actually behaves exactly like that.
*) Furthermore, take care of the objects permissions: if filesystem permissions to that source file or a directory (and it's content within) doesn't allow write operations to it, it will be copied again.

Related

I'm looking to have a Folder recognise new files being saved into it and then copy new files into a collated folder

In MacOS i want a folder action to trigger when i place a new file into a subfolder. The action should grab a newly added file to the folder and copy it to another folder where all the latest files are collated and can be viewed together. I also want the script to delete any old version of the same file it copies across to the collated folder. The trouble is the file names are slightly dfferent as they have a version number in them. The version number is defined as "v01a" to start with but can change to "v01b" or "v01e" or "v02a" or "v03c".
So if a file called "1234_ProjectName_Image01_COMP_v01a.jpg" already exists and a new file called "1234_ProjectName_Image01_COMP_v01b.jpg" is added the the file called "1234_ProjectName_Image01_COMP_v01a.jpg" needs to be deleted from the destination folder.
I've tried a few times to get started in automator but never really get the pieces in place for it to be useful.
(SOURCE)
Dailies/_Internal
Dailies/_Internal/Image01/1234_ProjectName_Image01_COMP_v01a.jpg
Dailies/_Internal/Image02/1234_ProjectName_Image02_COMP_v01a.jpg
Dailies/_Internal/Image03/1234_ProjectName_Image03_COMP_v01a.jpg
(DESTINATION)
Dailies/_Latest
Dailies/_Latest/1234_ProjectName_Image01_COMP_v01a.jpg
Dailies/_Latest/1234_ProjectName_Image02_COMP_v01a.jpg
Dailies/_Latest/1234_ProjectName_Image03_COMP_v01a.jpg
If a new file is added called
Dailies/_Internal/Image01/1234_ProjectName_Image01_COMP_v02a.jpg
then this file is copied from its source folder and put into the Destination folder.
(DESTINATION)
Dailies/_Latest
Dailies/_Latest/1234_ProjectName_Image01_COMP_v01a.jpg
Dailies/_Latest/1234_ProjectName_Image01_COMP_v02a.jpg
Dailies/_Latest/1234_ProjectName_Image02_COMP_v01a.jpg
Dailies/_Latest/1234_ProjectName_Image03_COMP_v01a.jpg
Here there is already an image with the same name except the version number so the script should also delete the old file leaving me with.
(DESTINATION)
Dailies/_Latest
Dailies/_Latest/1234_ProjectName_Image01_COMP_v02a.jpg
Dailies/_Latest/1234_ProjectName_Image02_COMP_v01a.jpg
Dailies/_Latest/1234_ProjectName_Image03_COMP_v01a.jpg
I can't for the life of me figure out how to do this, any ideas would be greatly appreciated.
Screengrab of my very basic automator here

OBIEE 12.2.1.2 Can not delete catalog folder? Error: Shortcut expected

I want to delete an old_folder from my shared catalog folders, however, the following error message is displayed: Shortcut expected /shared/old_folder/...
The same message appears in the catalog manager. Deleting single objects (analyses, prompts, ...) works fine: folders and subfolders within the given folder can not be deleted.
Concerning the permissions: I have full control of the folder/objects.
Ideas and suggestions are much appreciated!
Explanation: He means the .atr (Attribute files) which accompany any presentation catalog folder or file on the file system - i.e. phyiscally on the disk.
NOTE: This isn't something you do lightly.
a) Never touch just a file / folder without taking care of its accompanying .atr file
b) And vice versa. You can't just delete .atr files without also deleting their parent object - be it folder or file.
tl;dr - this should NOT be the very first you one does...

Create folder in selected folder with OS X Automator

I am trying to batch convert a bunch of raw image files on OS X. I would like to use built-in software since it is possible.
First I would like to
let the user select the input folder containing the raw files;
create a new folder jpgs inside of that folder;
copy the raw files from the user selected folder into jpgs.
This is the workflow I have implemented so far in order to implement the first two steps.
First I let the user select a folder and store it into the variable NEF Folder. The I create a new folder named jpgs in the folder chosen by the user (NEF Folder).
BUT this is what the workflow does after selecting folder AAA on the Desktop:
Why?
Understood.
The action New folder creates a folder and copies its input inside of the newly created folder.
I have the same issue and solved it checking the box "Ignore this action's input".

"Virtual Files" in OSX Finder that only appear when my Application runs, possible?

is there a way to "hook" into the OSX Finder to perform the following:
When my Application starts, the User sees a Folder in his Finder which is created by my application. Inside this Folder the User sees Files from several Folders...a unified view to several Files in several Folders that the User specified in my Application.
So, in this "Unified Folder" are not the real Files, they are still in there original Folder but the User sees them in this one Folder as if there were all his real Files in this new Folder. So there is no copying or moving involved.
To be honest, I've no Idea if it's possible and what I should looking for inside the Cocoa SDK. Maybe there is an API for the Finder itself or some other way?!
Regards
twickl
First option is your application could create aliases to the original files. The Finder will show these with a small arrow "badge" over the icon, so it is clear they are not the original files but aliases of them.
If you don't like the badges on the icons creating hard links may give you what you want.
Mac OS X presents a view of the HFS+ (Mac) filesystem which matches the UFS (Unix) one and you have access to hard and symbolic links. The latter are treated by the Finder similar to aliases but the former are indistinguishable from the original files as they are the original files - under the Unix filesystem a file in a directory is just a reference (the inode number) to the real file, each entry in a directory is just a hard link to the actual file, and a file can have any number of hard links to it (a file is deleted when the link count drops to 0, think of the retain/release model if that helps).
At the Cocoa level NSFileManager has methods to create hard links, or you can use the Unix level link(2) function.

Move folder cross disks without security descriptor change

I want to move a folder from one drive (e.g. C) to another (say D) without its security descriptor changed. SHFileOperation can move the folder, but new folder on D always inherit the permission from the parent folder. Not to impact other subfolders under the same parent folder, I cannot change the parent folder to stop propogating its permissions to its children.
I have used SetSecurityDescriptorControl with SE_DACL_PROTECTED to disable inherit when creating the folder on C. It seems not to work when move folder cross volumn. I also tried to set security info for the new folder on D, by removing old ACEs. However, those inherited ACEs cannot be removed.
There is a registry ForceCopyAclwithFile (http://thedailyreviewer.com/server/view/copy-folder-w-user-permission-intact-10274759) but I don't want to use it because of its global system impact.
How can I use windows API to move a folder cross disks without permission change? What did I miss here?
Thanks
Leon
You can use BackupRead and BackupWrite to move directories across volumes with NTFS security intact.
BackupRead: http://msdn.microsoft.com/en-us/library/aa362509(VS.85).aspx
BackupWrite: http://msdn.microsoft.com/en-us/library/aa362511(VS.85).aspx
You will need to create the folder at the destination first, then open both folders using CreateFile in order to get handles to them.
Your process will need to obtain the Backup and Restore privileges and you need to pass FILE_FLAG_BACKUP_SEMANTICS into CreateFile.

Resources