I'm getting the following error:
"The file isn’t compatible with QuickTime Player."
When using this script:
tell application "Finder"
set random_file to some file of entire contents of folder "Movies" of home
open result
end tell
However, I am able to open the file from the finder manually and once I do the script works on just that file. The problem is I have thousands of files and don't want to open each one manually for the script to work again. Have not had this problem with the script in the past.
There are two ways I can think of to approach modifying your script:
Stick with Finder's open command but invoke it fully with its using parameter, which accepts an application file that informs Finder of the application that will be used to open the file. It may sound superfluous given it already tries to open it in QuickTime, and we're not trying to change that, but it's not unwise to see if it does confer a difference in behaviour:
tell application id "com.apple.finder"
tell the folder (path to movies folder) to tell (the ¬
a reference to entire contents) to tell (the ¬
some document file as alias) to set f to it
open f using application file id "com.apple.QuickTimePlayerX"
end tell
Grab the file as you like (really, you ought to be using System Events for this, not Finder, but I'll go with what you had), but then use the open handler of the specific application to open the file:
tell application id "com.apple.finder" to tell the folder (path to movies folder) ¬
to tell (a reference to the entire contents) to tell (some document file) ¬
as alias to set f to it
tell application id "com.apple.QuickTimePlayerX"
activate
open f
end tell
NB. I'm using Monterey, in which both of these two above propositions work appropriately. This doesn't necessarily infer that it will do so in Big Sur, but if they do not, it's worth checking the various app permissions under the different Security & Privacy headings of System Preferences.
Related
I have this simple code in apple script which when run is supposed to rename the file. Instead it gives me an error Can’t get file "Volumes:Projects:Projects:1.pdf".
set ff to file "Volumes:Projects:Projects:1.pdf"
set ss to "Volumes:Projects:Projects:1.pdf"
set name of ff to ss
Three major issues.
To rename a file you have to tell Finder or System Events to do that.
A HFS path (colon separated) starts always with a disk name, never with Volumes.
To rename a file set the name property to a file name rather than to a full path.
Actually your example does nothing.
This snippet renames the file 1.pdf in folder "Projects" on disk Projects to 2.pdf
tell application "Finder"
set name of file "Projects:Projects:1.pdf" to "2.pdf"
end tell
Using the following example AppleScript code, with the existence of the file set to ff at the shown path:
set ff to POSIX path of "Volumes:Projects:Projects:1.pdf"
set ss to "2.pdf"
tell application "System Events" to set name of file ff to ss
Shows the following Event in Script Editor:
tell application "System Events"
set name of file "/Volumes/Projects/Projects/1.pdf" to "2.pdf"
end tell
Looking in Finder, 1.pdf was renamed to 2.pdf, as expected in this example.
Update: Note that vadian make a good point in 2 about the hierarchy of an HFS path, and is in part why I chose to covert it to a POSIX path. I also prefer to use System Events as it typically handle file operations faster than Finder and will work with both HFS style and POSIX style paths.
In other words, with System Events the following works:
tell application "System Events" to set name of file "Projects:Projects:1.pdf" to "2.pdf"
tell application "System Events" to set name of file "/Volumes/Projects/Projects/1.pdf" to "2.pdf"
But this too, even though malformed, works:
tell application "System Events" to set name of file "Volumes:Projects:Projects:1.pdf" to "2.pdf"
However, with Finder, only a proper HFS path works without error, it can't handle a POSIX path because it doesn't understand it as it's not in Finder's AppleScript Dictionary.
That said, one should always make sure the information being passed is properly formed even when a malformed path would work in this example with System Events, it's not a good habit to get into!
The file is inside the directory where the software is. I am trying to add the text file to the memo box.
procedure TForm4.FormCreate(Sender: TObject);
var
dir : string;
begin
Form4.Caption:='Abateri instrumente';
dir := GetCurrentDir;
Memo1.Lines.LoadFromFile(dir+'\abateri.txt');
end;
In your specific situation, you should load the file with the code
Memo1.Lines.LoadFromFile(dir+'\abateri.txt.txt');
This is because in the below screenshot that you provided, the extension of the Project3 file is hidden, which loads to the conclusion that the option to hide known file extensions is enabled. Yet the one for the abateri.txt file is shown, which can only lead to the often seen double extension mistake.
Either rename your file and remove the redundant part (the first .txt, which is preferred) or use the double extension in your code.
I would also suggest disabling that option in Windows Explorer:
Tools > Folder Options > View > Uncheck the "Hide extensions of known file types"
In addition to the above, you should always build up paths with the TPath.Combine function call to ensure that they are correct.
You can see the documentation of it here
The file is inside the directory where the software is.
In that case, looking in the working directory is the wrong approach. There's no reason why the working directory should be directory where your executable resides. You need to use:
Dir := ExtractFilePath(ParamStr(0)); // the directory where the executable resides
TPath.Combine(Dir, FileName); // TPath is from the System.IOUtils unit
Of course, your other problem is that you got your file name wrong. The file is actually named abateri.txt.txt.
I am using file handles to write my datasets to file in spss, which worked fine the first time.
FILE HANDLE directoryPath /NAME='D:\XX\Dropbox\XX\' .
FILE HANDLE write_data /NAME='directoryPath/dataset_1.sav' .
SAVE OUTFILE='write_data '
Now I get the following error:
>Error # 5332 in column 26. Text: write_data
>The specified file or directory is read-only and cannot be written to. The
>file will not be saved. Save the file with another name or to a different
>location or change the access permissions first.
>Execution of this command stops.
If I specify the full path rather than the file handle:
SAVE OUTFILE='D:\XX\Dropbox\XX\dataset_1.sav'
/COMPRESSED.
It works fine. As you can see, i am writing to a dropbox folder. I am not sure if this interferes with the permissions. Is there anyone that knows how to make my file handle example work by changing overall permissions, or do I need to revert back to changing my syntax manually?
File handles are not cumulative. Only the first portion can be interpreted as a file handle.
I am facing a following issue while adding a file to clearcase (UCM)
---------------------------
Rational ClearCase Explorer
---------------------------
Error adding 'M:\Myviename\Myvob\Myproj\Implementation\DataSource\Deployment\BOM\SupportFiles\Service.config' to source control.
Created branch "Tm6-Proj-Dev2" from M:\Myviename\Myvob\Myproj\Implementation\DataSource\Deployment\BOM\SupportFiles\Service.config' version "\main\0".
Type manager "text_file_delta" failed create_version operation.
I tried rebase and deleted and added the file again. But facing the same. Why this occured and how to solve it?
You will find all the know cases for this error message in this technote "Knowledge Collection: Type manager <text_file_delta> failed create_version operation"
Type manager size limitation - File too large
Text files that contain binary data - Contains a '\000'
Line exceeding 8000 bytes
Corrupt source container - not the highest on its branch
The main cause is a content incompatible with a text file (line too long, or binary content).
The OP Samselvaprabu adds:
Our IT guys used the following command "chtype Compressed_file".
After that it allowed to check-in.
As they did it in my collegue system, I was not able to ask what does this mean and how it solved the issue?
It does solve the issue (and it has nothing to do with UCM): since the text_manager doesn't recognized the content of the file as text (as illustrated, for instance, in this technote), you need to instruct ClearCase to treat it as binary content.
cleartool chtype compressed_file <filename>
Pro: it allows for checkin/checkouts
Cons: you won't be able to "compare with previous version" anymore.
You might need to instruct that compressed_file to be always copied over instead of merged (see "Clearcase UCM is trying to merge pdf files")
For certain set of files, you could also modify the magic file to automate that process: see "Check in to ClearCase fails".
Which type of view are you using ? Static(Snapshot) or Dynamic ?
check if file is already there on the main.
If the file is already there on main (which means file is Versioned file) then before editing you should check-out file and then after making changes you need to check in.
If you are using versioned file and you if made changes to this versioned file then it will be a hijacked file, (you will see red+green mark for on the file in clear case explorer).
Try out once.
I am trying to use a MEL script to load ANIMATION.MA file that references CHARACTER_RIG.MA. The CHARACTER_RIG.MA and ANIMATION.MA files are produced by someone else and supplied to me. The ANIMATION.MA is looking for N:/Project/Maya//char/character/CHARACTER_RIG.MA
If I open ANIMATION.MA from Maya, or use the equivalent MEL command I always get prompted with:
"Reference File Not Found"
Reference File Not Found: N:/Project/Maya//char/character/CHARACTER_RIG.MA.
[Abort File Read] [Skip] [Browse...] [Retry]
If I tap browse, and select the CHARACTER_RIG.MA then it opens perfectly. I can see it created a reference in the Reference Editor that has the Unresolved Path (N:/...) , the Resolved Path (/my/path) and the namespace and the namespaceRN.
My question is, how do I do the equivalent of the "Browse..." from MEL? I tried pre-creating a reference, but it doesn't let me set the unresolved path, so when I load the ANIMATION.MA it keeps prompting in MAYA.
file -f -options "v=0" -typ "mayaAscii" -o "/Source/project/assets/anims/ANIMATION.MA"
If you know the directory where the file is, then you can use the dirmap command. The command dirmap allows you to remap directory structures if your disk configuration changes. So in this case it would look like:
dirmap -en true;
dirmap -m "N:/Project/Maya//char/character" "/my/path";
Possibly more manageable if you have lots of mappings to do especially when moving form a windows machine to a *nix one. However it is much more useful to define your project structure because then things just work when you move, tough this may not be the best of choice for shared assets.
I ended up finding several solutions:
Rename the RIG.MA file to match the filename in ANIM.MA (they were different in my case) and put it in one of the search or project folders that MAYA uses and it will automatically find it.
or
Programatically through code (or manually) edit the ANIM.MA file to remap the file/folder of the RIG.MA to where you want to load it from. Note: You
also need to remap any other files, such as textures. I did this with
perl -pi -e 's/\Qold-path\E/\Qnew-path\E/g' ANIMATION.MA
HTH someone else.
Quick and easy, File, Project, Set and select the folder where meshes or whatever it is.