Check for a file to exist
Hi all, I have a script which returns the path for a file in this way:
set outfile to (choose file name with prompt "Choose output file." default name "out.iso")'s POSIX path
the path is then passed to the shell. Now, I want the script to check whether that file exists and if it does, the script needs to be stopped.
I tried some ways I found on the web but none seems to work.
Any help would be appreciated.
Thank you!
Lorenzo
Try using:
set outfile to (choose file name with prompt "Choose output file." default name "out.iso")'s POSIX path
set thefile to POSIX file outfile
tell application "Finder"
if exists thefile then
return --or other commands to stop script
end if
end tell
(57077)
Similar Messages
-
I'm running Vista for operating system on an HP laptop that's about 2 years old. I've installed all current updates.
I've always used Firefox. It started crashing and creating processes but not launching. Went to support and scoped it out -- there was a lock file my profile directory. I deleted it, and Firefox started loading.
Used it a few times -- closed the app each time on exist as per suggestions on support site info. One time -- back to square one, wouldn't load, just created a process. Reboot, ending process, checking for lock file, reinstalling -- all unsucessful.Brian
Below is from using a SIP build. It does offer G722, but it's way down on the list so it's never used...
m=audio 32678 RTP/AVP 0 8 18 102 9 116 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:102 L16/16000
a=rtpmap:9 G722/8000
a=rtpmap:116 iLBC/8000
a=fmtp:116 mode=20
a=rtpmap:101 telephone-event/8000
Taking Sreekanth's suggestion to try a Skinny build, I get the following when I make a call. It offers codecs in the order I SET THEM AND ONLY THE CODECS I SET! YAY!
m=audio 19374 RTP/AVP 9 0 101
a=rtpmap:9 G722/8000
a=fmtp:9 bitrate=64
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
Using a Skinny build on the phones also solved other issues. The phones use G711 when the whole path supports G711 and G722 when the whole path supports G722. It doesn't always use G722 and rely on transcoding for the call paths that can't use it. It's fantastic.. The phones also receive the QoS tagging that I set and that seems to result in better audio quality than on the SIP builds, which never did get those settings. Finally, it even solved a slow Exchange 2013 answer issue I have been experiencing for quite some time. I practically fell out of my chair when I saw everything that was fixed just by switching...
Cisco, PLEASE FIX YOUR SIP BUILDS! It's insane how the SCCP builds work perfectly and the SIP builds don't, especially with how much these phones cost.. I was thinking of possibly acquiring some 9951s, which are SIP only. I'm a little leery about that at this point. If they have the same kinds of issues as the SIP builds for the 7975g, there's no SCCP alternative to use..
Sreekanth
Thank you for suggesting a Skinny build.. That was about the only thing I didn't try. I am happy beyond belief that this is working so well now, even though the SIP builds should be just as well developed as the SCCP ones. -
How to check if the file already exists in the client directory
Hi all.
I'm on devsuite 10g. I'm using webutil to download files from DB using webutil function db_to_client.
What I need is to check if the file already exists in the client directory and if yes to display a message to ask the user if he wants to overwrite or no. How can I make this???
Here is the code that I'm using to download the file.
Thanks all for the collaboration.
Fabrizio
declare
file_path varchar2(2000) := null;
BEGIN
/** I ask where saving the file on the client machine **/
file_path:= webutil_file.file_selection_dialog
(directory_name => null,
file_name => :bin_docs.name,
file_filter => '',
title => 'Saving file',
dialog_type => save_file, --save_file
select_file => TRUE);
/** I download the file from DB to client **/
if webutil_file_transfer.DB_To_Client_With_Progress
( file_path ,
'BIN_DOCS',
'DOC' ,
'doc_id = '||:bin_docs.doc_id,
'Downloading file',
' '||:bin_docs.name) then
msg_alert('Download del file avvenuto con successo','I',false);
else
msg_alert('Si è verificato il seguente errore in fase di download '||SQLERRM,'I',false);
end if;
end;How about something like the below:
Note: I have a yes/no alert to asking if they want to over-write the existing file.
DECLARE
file_path VARCHAR2(2000) := null;
over_write BOOLEAN := TRUE;
BEGIN
/** I ask where saving the file on the client machine **/
file_path:= webutil_file.file_selection_dialog
(directory_name => null,
file_name => :bin_docs.name,
file_filter => '',
title => 'Saving file',
dialog_type => save_file, --save_file
select_file => TRUE);
IF webutil.file_exists(file_path) THEN
/** check a file by the same name exists in the selected directory **/
IF show_alert('Ask_overright') != alert_button1 THEN
/** If we say no then set over_write value to false **/
over_write := FALSE;
END IF;
END IF;
IF over_write THEN
/** I download the file from DB to client **/
IF webutil_file_transfer.DB_To_Client_With_Progress
( file_path ,
'BIN_DOCS',
'DOC' ,
'doc_id = '||:bin_docs.doc_id,
'Downloading file',
' '||:bin_docs.name) then
msg_alert('Download del file avvenuto con successo','I',false);
ELSE
msg_alert('Si è verificato il seguente errore in fase di'
||' download '||SQLERRM,'I',false);
END IF
END IF;
END;
cheers
Q -
Try to check whether a file already exists on disk by using fileExists
Hy all,
i try to check whether a file already exists on disk in my
Action scirpt.
I found this link about fileExists:
link
So i tried somethink like this in my code, but without
success...
if(fl.fileExists("file:///C|/toto.txt"))
{gotoAndPlay(2);}
else
{gotoAndPlay(3);}
Is it not the right syntax?
Thank you for your help.Did you build and application from the swf with mProjector?
The only
way this and other mProjector functions will get called is to
post
process your swf into and application (exe / app) using
mProjector.
you can get a free trial here
http://www.screentime.com/software/mprojector/demo.html
On 2007-01-08 16:02:42 -0500, "Alexis Schneider"
<[email protected]> said:
John Pattenden
Screentime Media - Flash Tools since 1997
http://www.screentime.com -
Check for updated file in physical drive and if exists then call procedure?
hi
i want to check on local drive in 1 folder if upated file is there and then start my batch process which will load data from that file.
so how to check if that file is present in location and its upated one
is there any utiliy in oracle ????
Reply ASAPUse UTL_FILE.FOPEN function with 'r' mode (read text mode). If it fails, then the file does not exist.
-
Text_io checking for the file exists?
When using TEXT_IO package procedures within a form, How can I check whether the file with the same name exits in the same file path?. I mean what is the text_io procedure? Is there any thing specific?
something like
EXCEPTION
when OTHERS then
if SQLCODE = -302000 then -- file problems
MSGBOX('Error: File could not be opened.');
raise FORM_TRIGGER_FAILURE;
else
MSGBOX('Error: ' || SQLERRM);
raise FORM_TRIGGER_FAILURE;
end if; -
How to check if a file (picture) exists into a war?
Hello, I have made a Java/J2EE project using countries in the world and I have at my disposition a folder of flags icons.
Some countries don't have any flag icon for any reason and in my application, I'll be able to add new ones.
In my code, I want to do display the flag of the current country if available else display a default icon.
Here is what I am currently doing:
String contextPath = facesContext.getExternalContext().getRequestContextPath();
String flagUrl = contextPath + "/images/flags/"+ name.trim().toLowerCase() + ".png";
boolean exists = (new File(flagUrl)).exists();The issue is exists is always set to true no matter the existence of the flag.
Here is what my variable nammed flagUrl looks like : /images/flags/ca.png
How do you check the existence of a file into a war? Thank you
Edited by: cotede3 on Mar 11, 2010 5:32 AMUnfortunately I cannot call getRealPath on application.
application in my code is :
BBrApplication application = null;
// Searchs entity class icon
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null)
application = BBrApplication.getInstance(facesContext);So I tried
String realFilePath = application.getContextRoot();but I end up with
realFilePath = /DFP/.
so It is not the absolute path displayed...
How can I do ? -
PL SQL block - Check for empty file
Hello,
I need help in writing pl sql code to check a file to verify if it has 0 records (file size = zero kb.) In a preceding pl sql block, I am performing a SELECT on data and writing it to a file. If that file is empty/has no records, then I would like to stop the process from continuing on to my next pl sql block which performs an update function.
Summary:
1) Create file from SELECT
2) Check file for zero data, if true, trigger error, if false, continue to next pl sql block.
3) Run update on records if data exists in the file.
Thanks in advance!Thanks John,
You've been of great help so far and a really appreciate it. I'm so close to getting this, I just need help with how to create an error when the file shows no data. I will be running this as an Oracle Apps Concurrent request. I'd like for the job to end in error when no data exists for the file. In unix, I can enter "EXIT 1" and it signals to the concurrent manager to put end the job with an error status. How can I do something similar using pl sql? Here is my code so far, with the missing piece. Thanks!
DECLARE
vFile UTL_FILE.FILE_TYPE;
vrecs BOOLEAN := FALSE;
vnodata EXCEPTION;
BEGIN
vFile := UTL_FILE.FOPEN('/devlop, 'norecs.txt', 'w', 32767);
FOR x IN (
SELECT
node_name AS txt
FROM
applsys.fnd_nodes
WHERE
node_name = 'blahblahblah'
LOOP
vrecs := TRUE;
UTL_FILE.PUT_LINE (vFile, x.txt);
END LOOP;
UTL_FILE.FCLOSE(vFile);
IF NOT vrecs THEN
RAISE vnodata;
END IF;
EXCEPTION
WHEN vnodata THEN
*<what can I put here to cause the pl sql block to error???>*
END;
/ -
Hi,
My requirement is as below:
In source FTP directory, I have to check if source file exists or not. If exists, that file shuld be picked up and created at target side with header, line items and detail record.
If the file does not exist, then a file should be created at target side with only header and detail record with no line item records.
In any case, a file should be created at target side.
Please suggest if Dynamic configuration is the better option for this or any other way gives better results.
Thanks and Regards,
Anil.@ Babu,
The query is like...
If the file does not exist, then a file should be created at target side with only header and detail record with no line item records.
In any case, a file should be created at target side.
so i answered as,
Now when the file is not present, u will get only the empty tags..(message type name in XML Payload)
If you read the question carefully, it is not being asked "how to handle empty files". It is about "what to do if there are no files in the source directory", which implies that if there are no files present, then create one.
u said as,
This option won't "create" an empty file.
Correct me if i am wrong, DID I SAY IT WILL CREATE an EMPTY FILE IN SOURCE FOLDER???
No, you don't need to say that .. it was evident from your answer. In this forum post, nothing is being asked regarding empty files, so please don't provide such answers which has nothing to do in this situation.
-- Abhi -
Checking for a file in a dir + all subdir's
i'm checking if a file exists in C:/, and all sub directories of C:/. It's easy enough to scan for it in the parent directory, but how would i go about checking all the sub directories also? I couldn't get a system of using the boolean isDirectory working, here's what I have though:
import java.io.File.*;
import java.io.*;
class Readit {
File file;
Readit(String fileName) {
file = new File(fileName);
check(file);
void check(File file) {
try {
if(file.exists()) {
String files[] = file.list();
for(int i = 0; i < files.length; i++) {
System.out.println(files);
File subdir = new File(files[i]);
if(subdir.isDirectory()) {
String infil[] = subdir.list();
}{color}
} catch(NullPointerException nul) {}
public static void main(String[] args) {
Readit r = new Readit(args[0]);
}Edited by: Pattylulz on Jun 10, 2008 8:43 PMIt is not clear what exactly you need.
I assume that you want to find recursively a file/folder with given name:
private static final FileSystemView fsv =
FileSystemView.getFileSystemView();
private static final File checkFile(File pathParent,
String name) {
final File[] list = pathParent.listFiles();
if (null == list)
return null;
File pathFound = null;
for (int i = 0; i < list.length && null == pathFound; i++) {
final File pathCur = list;
// Can use system display name or name (pathCur.getName())
final String nameCur = fsv.getSystemDisplayName(pathCur);
// If you need to search only files, use: pathCur.isFile()
if (name.equalsIgnoreCase(nameCur)) {// or equals
pathFound = pathCur;
} else {
// All traversable items, but skip links to folders
boolean isLink = false;
try {
isLink = ShellFolder.getShellFolder(pathCur).isLink();
} catch (FileNotFoundException e) {
if (fsv.isTraversable(pathCur) && false == isLink) {
// Recursive is subfolders
pathFound = checkFile(pathCur, name);
return pathFound;
public static void main(String[] args) {
File file = checkFile(new File("C:\\"), args[0]);
if (null != file)
System.out.println("File is found: " + file);
else
System.err.println("Cannot find file with name: " + args[0]);
Mimo -
Need script to check for duplicate file names when copying a folder
Hello,
I am a new applescript user trying to write what I believe should be a simple script. I was planning on using the "add-new item alert" script as a template.
Basically I have people copying folders of photos into a library folder, but I don't want the Finder to copy the photo if it already exists in the library. The images in the library are organized into subfolders.
I need a script that will check all the file names in the new folder against all the file names in the library, and NOT add the new one if it already exists.
If anyone can help it would be greatly appreciated,
Thanks,
CI have a script that "kind of" works. The only problem I've seen is that it gets confused when filenames contain characters that are fine in Macland but not good in Unixland. Forward slashes are a good example of this.
In this case I have a folder in my home named "copytest" Inside copytest are two folders:
Source (containing the images to be added)
Dest (My existing library of images)
It also assumes that the folder of images to be added contains no sub-folders. Hope this helps.
tell application "Finder"
set theSource to folder "source" of folder "copytest" of home
set imagesToBeCopied to name of every file of theSource
end tell
repeat with theFile in imagesToBeCopied
try
if (do shell script "find -r ~/copytest/dest -name " & quoted form of (theFile as string)) is not equal to "" then
--The file exists. Don't copy it
else
--the file doesn't already exist. Copy it.
end if
on error
return "Failed while trying to check for existence of a file"
end try
end repeat -
Check for Duplicate files.
I have multiple folders with duplicate files, i was wondering what is the best way to check for duplication based on file content even if the file name is slightly different.
There are several commercial software options. I suggest that you use the ones that use SHA1 matching.
Decloner is pretty good, and it comes with a 30-day trial that is FULL FEATURED.
http://www.pixelespressoapps.com/decloner/
Only works on snow leopard and up.
Their website conviniently compares other duplicate file software packages.
I purchased Twins, which is also great.
http://www.rockysandstudio.com/apps/twins
Only works on Lion and up.
Remember, SHA1 is the way to go if you want to find duplicates with highest accuracy. -
Hi,
I created a thread that "scans" a given folder for files. If any file is found then i move that file to another location, the problem arises if i have one application(example: Microsoft Word) saving the files there, and the thread "grabs" the file, before the process of saving is completed.
How do i solve the problem? I thought in checking if the file is open, then the thread should touch it, but how do i check if the file is open or closed?
Thanks in Advance,
MrNiceLifeThe claim has been made that "NIO" in jdk 1.4.x gives methods for dealing with this problem.
-
How to check if the file already exists in the application server directory
Hi all. I'm on devsuite 10g.
I transfer file from local machine to application server using webutil function webutil_file_transfer.client_to_as and I want to check if the file I'm transfering already exists on the server directory.
How can I make this?
Thanks all,
Fabriziouse the text_io package and open the file in read-mode.
like this
declare
xFileType text_io.file_type;
begin
xFileType := text_io.fopen('c:\temp\test.txt','R'); --file on the middle tier
-- file exists;
text_io.fclose(xFileType);
exception
when others then
--file doesn't exist
end;
regards
Christian -
Hi
Is there a way for checking the availability of a file in the sender system folder in PI 7.0?hi
if you done all these desingn and configuring part
copy the xml format file and paste in to the source file in your woek space
then check the Runtime workBench
in that check the component monitoring
in that check the communication
and check your sender file is going to the XI or not. if it is green then it is send atherwise having the problem
check
thanks
Regards
vijay
Maybe you are looking for
-
Hello. I've tried my best not to have to post a new topic, but I have now downloaded at this point more than 2 gigs of Itunes and to no avail. I am running Windows XP 64 bit, NOT Vista 64 bit, NOT windows 7 and was wondering is there something I coul
-
Hi, I own a powerbook G4 and a Samsung Syncmaster 710t with pivot abbility, now i want to know if it's possible to turn the picture a 180 degrees on my powerbook?
-
Summary row in tableview (including sorting and BYPAGE navigation)
Hello everybody, I already found a few topics dealing with this problem but I wasn't able to find a real solution for this. So far I'm pretty familiar with table iterators but I have no idea how to handle the summary row to be the last line in a tabl
-
Hi all. Ive edited my css on my site and tried to upload it using dw cs4 ftp, it uploads all new images and stuff but not the css. This is the modified css having just added the label rule (in green): .page-container .main .main-content .column1-unit
-
Question about an HP Deskjet 1050 print, scan and copy
I'm trying to scan something so that it goes on the computer and not print a copy. Can you help me?????