hi everyone,
i tried to make a script for make folders with the names of files contains in a specific folder in a selected destination.
after that i want in every folder a nuke files (nuke is a vfx program, the files are text readable) will be create with an auto setup for every shot
But that don’t work at the first step
this is my script
set sourceFolder to (choose folder with prompt "Files Folder")
set destinationFolder to (choose folder with prompt "Files Destination folder")
tell application "Finder" to set theFiles to files of sourceFolder
repeat with aFile in theFiles
set Nom to name of aFile
set {Nom_clr, text item delimiters} to {text item delimiters, "."}
set customer to text item 1 of Nom
set text item delimiters to Nom_clr
make new folder at destinationFolder with properties {name:Nom}
end repeat
display dialog "Your folders are succefully created." buttons {"Thanks"}
the Finder tell block must wrap the whole repeat loop, only the Finder can create a folder.
This is a version without text item delimiters
set sourceFolder to (choose folder with prompt "Files Folder")
set destinationFolder to (choose folder with prompt "Files Destination folder")
tell application "Finder"
set theFiles to files of sourceFolder
repeat with aFile in theFiles
set {name:Nm, name extension:Ex} to aFile
set Nom to text 1 thru ((get offset of "." & Ex in Nm) - 1) of Nm
make new folder at destinationFolder with properties {name:Nom}
end repeat
end tell
display dialog "Your folders are succefully created." buttons {"Thanks"}
tell application "TextEdit"
activate
make new document
set Nuke to current date
set text of document 1 to Nuke as text
set nameNuke to (aFile as string) & ".txt"
save document 1 in nameNuke
end tell
Does it exist a way to create text files with a custom text inside without opening text editor please ?
thanks for your help
property myText : "myText"
property destinationFolder : missing value
set sourceFolder to (choose folder with prompt "Files Folder")
set destinationFolder to (choose folder with prompt "Files Destination folder")
tell application "Finder"
set theFiles to files of sourceFolder
repeat with aFile in theFiles
set {name:Nm, name extension:Ex} to aFile
set Nom to text 1 thru ((get offset of "." & Ex in Nm) - 1) of Nm
make new folder at destinationFolder with properties {name:Nom}
my createTextFile(Nom)
end repeat
end tell
display dialog "Your folders are succefully created." buttons {"Thanks"}
on createTextFile(fileName)
try
set destinationFile to ((destinationFolder as text) & fileName & ":" & fileName & ".txt")
set dataStream to open for access file destinationFile with write permission
write myText to dataStream
close access dataStream
on error
try
close access file destinationFile
end try
end try
end createTextFile
yes you can
theFile : is a string containing the macintosh path
theContents : is a string to store in the file
try
set fd to open for access file theFile with write permission
set eof of fd to 0
write theContents to fd as string
close access fd
on error
close access file theFile
end try
sorry I up the post, I don’t find how to do that.
I explain again my problem
I want create a text file for make a custom nuke files but the problem is applescript see the text like a code (because it’s a code) how is possible to force applescript to interpret it like a text and keep the possibility to put applescript variable inside ?
Thanks
property myText : "#! /Applications/Nuke6.1v2-32/Nuke6.1v2.app/Contents/MacOS/Nuke6.1v2 -nx
version 6.1 v2
define_window_layout_xml {<?xml version="1.0" encoding="UTF-8"?>
<layout version="1.0">
<window x="0" y="22" w="1440" h="874" screen="0">
<splitter orientation="1">
<split size="910"></split>
<splitter orientation="1">
<split size="40"></split>
<dock id="" hideTitles="1" activePageId="Toolbar.1">
<page id="Toolbar.1"></page>
</dock>
<split size="866"></split>
<splitter orientation="2">
<split size="424"></split>
<dock id="" activePageId="Viewer.1">
<page id="Viewer.1"></page>
</dock>
<split size="424"></split>
<dock id="" activePageId="DAG.1">
<page id="DAG.1"></page>
<page id="Curve Editor.1"></page>
</dock>
</splitter>
</splitter>
<split size="526"></split>
<dock id="" activePageId="Properties.1">
<page id="Properties.1"></page>
</dock>
</splitter>
</window>
</layout>
}
Root {
inputs 0
name "/Users/ThOr/Desktop/nuke base.nk"
first_frame 0
last_frame 6200
lock_range true
format "2048 1556 0 0 2048 1556 1 2K_Super_35(full-ap)"
proxy_type scale
proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)"
}
Read {
inputs 0
file "/Users/ThOr/Desktop/GOT MILK/MASTER_GOTMILK_TGA/Got_Milk_MASTER_DEF-prores-25p_%05d.tga"
format "4096 3112 0 0 4096 3112 1 4K_Super_35(full-ap)"
first 0
last 6200
name Read1
xpos 32
ypos -174
}
Write {
file /Users/ThOr/Desktop/render_%d05.tga
file_type targa
checkHashOnRead false
name Write1
xpos 32
ypos -60
}
Viewer {
input_process false
name Viewer1
xpos -40
ypos -9
}"
on createTextFile(fileName)
try
set destinationFile to ((destinationFolder as text) & fileName & ":" & fileName & ".nk")
set dataStream to open for access file destinationFile with write permission
write myText to dataStream
close access dataStream
on error
try
close access file destinationFile
end try
end try
end createTextFile
Hi again
i’ve find a solution with a huge simplification of nuke files
but I still have a problem…
in the text value, I can’t put a variable (aFile and Format)
how i can do it please ?
thanks again
property myText : "#! /Applications/Nuke6.0v7-32/Nuke6.0v7.app/Contents/MacOS/Nuke6.0v7 -nx
version 6.0 v7
Root {
format "Format"
}
Viewer {
input_process false
name Viewer1
}
Read {
inputs 0
file "aFile"
name Read1
}
Write {
name Write1
}"
property destinationFolder : missing value
--project files creation
on createTextFile(fileName)
try
set destinationFile to ((destinationFolder as text) & fileName & ":" & fileName & ".nk")
set dataStream to open for access file destinationFile with write permission
write myText to dataStream
close access dataStream
on error
try
close access file destinationFile
end try
end try
end createTextFile
Split the text property into 3 parts.
The variables myFormat and myFiile must be defined as globals or local within the createTextFile() handler
property myText1 : "#! /Applications/Nuke6.0v7-32/Nuke6.0v7.app/Contents/MacOS/Nuke6.0v7 -nx
version 6.0 v7
Root {
format "
property myText2 : "
}
Viewer {
input_process false
name Viewer1
}
Read {
inputs 0
file "
property myText3 : "
name Read1
}
Write {
name Write1
}"
property destinationFolder : missing value
--project files creation
on createTextFile(fileName)
try
set destinationFile to ((destinationFolder as text) & fileName & ":" & fileName & ".nk")
set dataStream to open for access file destinationFile with write permission
set textToWrite to myText1 & myFormat & myText2 & myFile & myText3
write textToWrite to dataStream
close access dataStream
on error
try
close access file destinationFile
end try
end try
end createTextFile
the number of parameters in the handler call must match the number of parameters in the handler definition.
You have to pass also the contents of myFormat, aFile and renderFile.
Note that in this case all parameters must be strings otherwise you’ll get the next error
renderFolder isn’t defined in the handler.
Note that the scope of variables is always limited to the current handler (the main script is actually within the implicit run handler).
To make variables visible from everywhere, declare them as global or property or pass them as parameters