File exists warning
I wanted to write a generic solution for save dialogs where you're going to be overwriting the file. Because getSelectedFile is called a whole bunch before the dialog is closed and a choice made, the only way I could figure out how to do it was to add a PropertyChangeListener and listen for the ancestor property.
Is there a better way to do this?
here's my code
* Created on May 17, 2005 by @author Tom Jacobs
package tjacobs.ui;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileSystemView;
import tjacobs.ui.fc.FileExtensionFilter;
public class JFileChooser extends javax.swing.JFileChooser {
private boolean mWarnOnWriteOver = false;
private boolean mAncestorNull = false;
public JFileChooser() {
super();
init();
private void init() {
addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent pe) {
//System.out.println("Here");
System.out.println(pe.getPropertyName() + ": " + pe.getNewValue());
if (pe.getPropertyName().equals("ancestor") && pe.getNewValue() == null) {
mAncestorNull = true;
public JFileChooser(String arg0) {
super(arg0);
init();
public JFileChooser(File arg0) {
super(arg0);
init();
public JFileChooser(FileSystemView arg0) {
super(arg0);
init();
public JFileChooser(File arg0, FileSystemView arg1) {
super(arg0, arg1);
init();
public JFileChooser(String arg0, FileSystemView arg1) {
super(arg0, arg1);
init();
public boolean getWarnOnWriteOver() {
return mWarnOnWriteOver;
public void setWarnOnWriteOver(boolean b) {
mWarnOnWriteOver = b;
public File getSelectedFile() {
File f = super.getSelectedFile();
if (f == null) return f;
if (getDialogType() == super.SAVE_DIALOG && f.getName().indexOf(".") == -1) {
//check if it's using file extension filter. If so, add the filter extension
FileFilter ff = getFileFilter();
if (ff instanceof FileExtensionFilter) {
String ending = ((FileExtensionFilter)ff).getType();
f = new File(f.getParent() + getName() + ending);
//now check if it's overwriting another file
//System.out.println("isVisible: " + this.isVisible());
if (mWarnOnWriteOver && mAncestorNull) {
if (f.exists()) {
int ans = JOptionPane.showConfirmDialog(null, "" + f.getName() + " exists. Overwrite?", "Save Over Existing File", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (ans == JOptionPane.OK_OPTION)
return f;
return null;
return f;
}
I would go the composition route rather than the inheritance route in this case. Then you won't have to worry about all the internal workings of a JFileChooser:
public interface FileSelector {
public File getFileToSave(..., boolean warnIfExists);
public File getFileToOpen(...);
class FileSelectorImpl implements FileSelector {
private JFileChooser fc;
public File getFileToSave(..., boolean warnIfExists) {
// Get the File the standard way from the internal JFileChooser.
// If it exists and warnIfExists is true, show the confirmation dialog
}
Similar Messages
-
Check if a file exists in network dir (JS)
I've found an old post that has pointed me at:
if (myFile.exists){
alert("File Exists");
else
alert("File doesn't exist");
The problem is that when I use the path macname/volumes/dir/folder/folder/file.indd (which was created from variables) as myFile the script doesn't find a file that I know exists. All I get is the "File doesn't exist" alert.
Do I need to define myFile as being a string?
I'm still fumbling my way around JS, and converting Applescripts to JS to work cross-platform. Thanks in advance....To get the path to a file i normally use this little script:
// JavaScript Document
var myFile = File.openDialog("Choose a File");
if((myFile != "")&&(myFile != null)){
alert("Path: " + myFile + "\nType: " + myFile.type);
Perhaps this c/p can help you:
function mounter() {
var myDocument = app.activeDocument;
// we are saving the preview
var destination = "/Volumes/myfoldername";
//var destination = "/Users/tn/Documents/Tryksager/Design/";
var volume = "afp://sub.dn.com/myfoldername";
try {
with (myDocument) {
if(file_name = get_filename(name)) {
if (Folder(destination).exists) {
//alert("Folder exists: " + Folder(destination));
} else {
if (confirm ("Mount volume?", false, "Mount volume")) {
mount_volume();
// volume mounted, do what you need
} else {
alert("Could not mount");
} catch ( err ) {
// No error warning
function mount_volume() {
var myScriptFolderPath = pluginPath + "/resources/"; // Path to the applescript
app.doScript(File(myScriptFolderPath + "mountvolume.scpt"),ScriptLanguage.applescriptLanguage);
//The applescript for mounting volumes
(*set user_name to ""
set Dialog_1 to display dialog "Please enter your user name" default answer ""
set the user_name to the text returned of Dialog_1
set pass_word to ""
set Dialog_2 to display dialog "Please enter your password" default answer "" with hidden answer
set pass_word to the text returned of Dialog_2*)
tell application "Finder"
try
mount volume "afp://mysub.mydn.com/myfolder" as user name "myusername" with password "mypassword"
end try
end tell
Thomas B. Nielsen
http://www.nobrainer.dk -
How to check whether file exist in a folder at the application server
Hi to all experts.
if suppose there is a file at the application server test.txt my requirement if the one more file is created of the same name before overwriting the file a warning message is to displayed to the user that the file already exist .
how to do itHI Mohammed,
use The FM DX_FILE_EXISTENCE_CHECK
or static class CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
For more info
search file in application server
application server
hope it helps you.
Regards! -
Exporting CSV can overwrite files without warning
Warning about an undocumented, automatic deletion of files by Numbers.
Export a iWork'09 Numbers (Version 2.0.5 (368)) document (with 2+ sheets) as a CSV with the same name as a folder in the destination and WHAM!
Yes, WHAM - it deletes all files in that folder with no warning (and they are not sent to Trash, oh moan, on moan).
A scenario - MyData.numbers (with 2+ sheets) stored in a MyData folder on the Desktop. Open it, export as CSV to Desktop, it deletes everything in folder including itself and replaces them with Sheet 1-Table 1.csv, etc. There is no warning this will happen.
If there is only one sheet, it will create a MyData.csv on the Desktop and leave the folder alone. If you do it again with one sheet, it will warn you the file exists.
If you repeat it with a 2+ sheet document again, there is not warning, this time csv files in the folder will be replaced.
This is horrid, unruly behaviour and cost me a huge amount of time repairing the damage.
There is nothing in the user guide to prepare me for this unhappy event.
You have been warned. Apple please fix this.I must say that you are right on one point.
Even if I feel that this format is the worst ever invented, I exported many times Numbers documents in csv format. I never go the described behavior.
So, as I am honest, I created a folder with the same name than the stripped document's one.
When I asked the app to export it, the save dialog displayed the default name : azertyuiop.csv
As the folder was named azertyuiop, I was sure that there will not be any kind of problem.
I was wrong and you were right.
The result was not a folder azertyuiop.csv but the folder azertyuiop.
Of course, I decided to check that I wasn't fooled by my memory.
I made an other attempt with the name azertyuio.csv.
This time, there was no existing folder. I was sure that I will get the object azertyuio.csv
It's what my memory was repeating me.
Alas, the result was a folder named azertyuio.
So, I stop this message here and enter the Bug Reporter area.
Yvan KOENIG (VALLAURIS, France) mardi 14 juin 2011 17:25:01
As my Internet connection is in maintenancecr, I was unable to post it at the date_time used in my signature.
So I had time available to preparer a bug report.
Here it is :
Bug ID# 9608202.
Summary:
Awfull behavior of Numbers
Steps to Reproduce:
Create a Numbers document with several tables.
Export it as csv.
The Export dialog offer a name, say azertyuiop.csv
Expected Results:
Several users and myself assumed that we will get an object named azertyuiop.csv containing one csv file for every existing table.
Actual Results:
in fact, what we get is a folder named azertyuiop (without the name extension displayed in the dialog)
Worse, if a folder already exist with this name, THERE IS NO WARNING ISSUED.
So, the entire content of the existing folder is destroyed.
It’s really the worst kind of bug which I may imagine.
Regression:
Triple check that there is no existing folder with the same name than the document to export.
Or no longer use the dedicated menu when we want to export as csv but trigger this AppleScript which will take care to build a unique name.
--{code}
tell application "Numbers"
tell document 1
set dName to name
set dPath to path
end tell
end tell
if dPath ends with ".numbers" then
set barePath to text 1 thru -9 of dPath
else
set barePath to dPath
end if
set csvPath to barePath & (do shell script "date +_%Y%m%d_%H%M%S.csv")
tell application "Numbers"
save document dName in csvPath
Yes, it's foolish but if the document contain several tables,
the result will be the folder azertyuiop_20110614_174726.
Only the enclosed files will be named table 1.csv, table 2.csv…
end tell
--{code}
Yvan KOENIG (VALLAURIS, France) mardi 14 juin 2011 21:12:17
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
Please : Search for questions similar to your own before submitting them to the community
To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer ! -
How to check if a specific file exist and which exit code to use ?
Hi, First I'm not a scripting guy and I know almost nothing about VB scripting.
I have a deployment of 6 tasks and I want to make sure that step # 2 will not be process if it failed in step #1, and so on for the 6 task.
To do this, i have to run a vb script before installation or uninstalltion on each steps
I'm trying to use a script (not from me) that i have modified for pre-uninstallation of software and also post-installation of the software.
Pre-uninstallation: The script will look if the specified "exe" exist on the server and if so, than it will run the msiuninstall "application_name".
If the uninstallation is successful, the post-installation script will check if the "exe" file exist again on the server, and it shouldn't find it (because it was deleted from the uninstallation), than it will return an exit code of successful
to run the next process.
Here an example:
Step 1: Uninstall "Software#1" with msiuninstall Software#1.exe command
Step 2: Uninstall "Software#2" with msiuninstall Software#2.exe command
Step 3: Install "Software #3"with an .exe extension
Step 4: Re install "Software #2" with an .msi extension
Step 5: Re install "Software #1" with a .msi extension.
Step 6: Send email to confirm the deployment is successful
So i need to validate that step #2 will not process step #3 if it failled on # 2. It need to validate if the file exist before and after.
At the end, Step 6 should send an email to confirm that the 6 steps of the deployment was completed without errors.
Any idea how to do it ?
Many many thanks for all the help !
A desperate guy :)
This is what i have
'This script will look if an .exe file exist for a specific application.
'=============================================================================================
path = WScript.Arguments.Item(0)
set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(C:\Inetpub\wwwroot\Enterprise\EnterpriseWS\web.config) = true then
exitCode = 0
else
exitCode = 1
End If
Wscript.Quit exitCodeSince you are not a scripting guy here is a very good place to start:
http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx
¯\_(ツ)_/¯ -
OK, i create a directory i have read/write permissions on the directory, but still even if the file exists its bringing back the result as if it doesnt i need help with this...
set serveroutput on
DECLARE
fexists BOOLEAN;
flen NUMBER;
bsize NUMBER;
BEGIN
sys.utl_file.fgetattr('TMP_LOCATION', 'test.txt', fexists, flen, bsize);
IF fexists THEN
dbms_output.put_line('File Exists');
ELSE
dbms_output.put_line('File Does Not Exist');
END IF;
dbms_output.put_line('File Length: ' || TO_CHAR(flen));
dbms_output.put_line('Block Size: ' || TO_CHAR(bsize));
END fgetattr;
File Does Not Existmy directory.. CREATE or replace DIRECTORY tmp_location AS 'Server-1\configsheets\completed\pdf approved'Good afternoon,
If you are loooking at a mapped drive, you can only see it if you change how the Oracle services start. You need to have them start with a specific user ID rather than starting as system services. The problem is that the system services cannot see mapped drives.
So, do this:
<li>Create a user to be used by Oracle services. Make sure they have the correct rights (I gave mine Server ADMIN so as to have all the access I needed)
<li>Log into the server and modify the services
<li>Click the 'Log On' tab and enter the account and password you created for the Oracle Processes
<li>Reboot the server, allowing the Oracle services to log in with this new ID.
This should then fix your problem.
Thanks,
Don.
REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone! :) -
I am using SQL Server 2005. I run a report which runs and renders perfectly. But I am unable to export it into any format. It fails with the following error:
Server Error in '/Reports' Application.
The file exists.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.IOException: The file exists.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[IOException: The file exists.
Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream outputStream, String& mimeType, String& fileNameExtension) +489
Microsoft.Reporting.WebForms.ServerReport.InternalRender(Boolean isAbortable, String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +924
Microsoft.Reporting.WebForms.ServerReportControlSource.RenderReport(String format, String deviceInfo, NameValueCollection additionalParams, String& mimeType, String& fileExtension) +84
Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +153
Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +75
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +303
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
I have seen this question asked several years ago, but have never seen a response that suggests what the issue may be.
I would really appreciate any help in resolving this problem.\
The application has been running from quite some time and this problem started just recently.
Thank You.
-RickHi Rick,
According to your description, the exception “System.IO.IOException: The file exists.” is thrown out when you export the report on report manager.
Generally, the exception is thrown out because there are more than 65535 files without deleting previous temporary files in our temporary directory. Based on my research, it has reported the same issue when exporting the report on report manager, and deleting all
temp files from C:\Windows\Temp could resolve the issue. I would also suggest you remove the temporary files from C:\Users\<username>\AppData\Local\Temp. Please refer to the first comment at this link:
System.IO.IOException: The file exists
Reference:
Path.GetTempFileName Method
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
Open File - Security Warning with Network-based Silent Install of CS4
I am attempting to run an enterprise deployment of CS4 Design Standard Edition onto a pool of WinXP Pro workstations. I placed all of the install files on a networked server running Windows 2003, and generated from there all of the requisite .xml files (install, uninstall, and override files). From this network share, I can successfully run a silent install.
HOWEVER. Multiple times (two or three) during the course of the silent install, I receive the same pop-up security warning from Windows XP (definitely an OS message, not anti-virus or other) that reads as follows:
Open File - Security Warning
Do you want to run this file?
Name: AIRApplicationRunner.exe
Publisher: Adobe Systems Incorporated
Type: Application
From: (server IP address)
I have tried excluding Adobe Air from the installation package, but I still receive the same security prompt. This is sufficiently a hassle to have to click through these prompts in a silent install. But more importantly I am unable to run the silent install as part of a logoff script because for all intents & purposes it is no longer a silent install (i.e. it requires user intervention). To top it off, I found when testing the logoff script the prompts are suppressed and the installation fails prior to the bulk of the installation (Photoshop, Illustrator, & InDesign).
I'm sure that I could run the install by copying all of the files to each local workstation, but again that would defeat the purpose of an easy, network-based install. In the past I was able to install CS3 in this fashion with no troubles, which of course did not include Adobe Air.
Can anybody offer a suggestion as to how to disable these security messages, or alternately, how to entirely exclude Adobe Air from the install package? I have found a VB script that is supposed to address the security warnings issue, but to run the script also requires the user to accept it at a security prompt.
Thanks in advance for any assistance!
-DanI'm now able to deploy design suite premium cs4 successfully.
The issue for me was that the AirapplicationRunner installs some useless software. I worked around the issue with the Airapplicationrunner prompt by removing any apps that are installed using that method. By "removing" I mean marking that app as "donotinstall" in the deployment file. The apps I removed are these adobe codes for adobe media player, adobe.com, adobeair itself. The below is from my deploy.xml file used for the silent workflow:
donotinstall
donotinstall
donotinstall
If you mark those three adobe codes as "donotinstall" the prompt never appears and the real apps get installed just fine. -
Disable "Open File Security Warning"
Hi whenever I try to open a file from the local hardrive I get the "Open File Security Warning" asking me whether I want to open the file or not. This is getting rather annoying. I searched online but everything I found seems to be dealing with network shares and I am not using that. Just a file on the local hard drive in the computer I am using to the right of me. I remember in my last install I turned it off somehow, but for the life of me I can't figure out how I did it. Anybody have any ideas? Or is this here to stay?
Windows 7 - Launching unsafe files is in this path;
IE -> Internet Options -> Security tab -> Custome Level -> Scroll down in Settings -> Look for radio button "Launching applications and unsafe files (not secure)".
Don't know if it solves the problem or not but option is there.
Great, on Windows 8 x64 this is an option I can find and set.
It will generate a nasty warning in the system tray. And does not solve the problem:
I have downloaded a warez archive and extracted it. The resulting .exe file is a wrapped program which will extract everything to my choosings. I've used it before.
When I try to run the program, all I get is:
Windows Security
These files can't be opened
Your internet security settings prevented one or more files from being opened.
Show details | Close
I do not use IE, I use chrome. What is this strange behaviour?? :(
Post-EDIT: I found this link with detailed steps for Windows 8, including screenshots.
http://www.c-sharpcorner.com/UploadFile/e83792/how-to-disable-the-open-file-security-warning-in-windows-8/
But this does not solve my particular problem :s
... Peace!
Devvie
~~~ [email protected] ~~~
Cuisvis hominis est errare, nullius nisi insipientis in errore persevare
All spelling mistakes are my own and may only be distributed under the GNU General Public License! – (© 95-1 by Coredump; 2-013 by DevNullius)
2nd POST-EDIT: I solved it with a little tool: streams! Read more here: http://scforum.info/index.php/topic,8543.msg22024.html#msg22024 and be done with this IE sheit. Who uses IE anyways and why is it important when I want to run a local file :| The future
looks grimm :( -
Dialog prompt and check if file exists, and use the result of dialog
I have this working script and I want to change the way it behaves.
I want a dialog to come up, Do you want to skip or replace existing files.
Then the result of the dialog to be used in the reast of the script.
I've added it in the script where I need to use it. in noce big letters, hopefully its not a big job.
Many thanks
property type_list : {"8BPS"}
property extension_list : {"psd"}
script o
property theseNames : {}
end script
-- empty log file
do shell script "echo 'Files not processed in Photoshop :' > ~/Desktop/LogPhotoshopError.txt"
set noError to true
--Setup list of folders and process details of folders
set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
set tc to (count dtF)
repeat with i from 1 to tc
set folderName to item i of dtF --<: is the folder name, no need to use text item delimiters -->":"
if folderName does not start with "2_" and folderName does not start with "Hot" and folderName does not start with "Press" and folderName does not start with "Design" and folderName does not start with "Keywords" and folderName does not start with "Season" and folderName does not start with "Sue" and folderName does not start with "Design" then
set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
set FolderEndName to last text item of folderName
set brandName to first text item of folderName
set my text item delimiters to "_PSD"
set weekNumber to first text item of FolderEndName
set my text item delimiters to oldTID
set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)
--set up names to destination folders and create locally based on brand name and week number
set this_local_folder to "Images:2012-2013"
set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
set this_Network_folder to "GEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
set website_images to "GEN:Website_Images:"
--set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
set this_ftp_folder to "pulse:"
set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
--at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
--use the result for the if file exists?
display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
--taking the folder identify which process it must follow.
if brandName is equal to "BH" then
try
tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
on error
set o's theseNames to {} -- no psd files or "8BPS"
end try
set numOfNames to (count o's theseNames)
repeat with j from 1 to numOfNames
set thefile to theFolder & ":" & (item j of o's theseNames)
-- B H Folder Photoshop Process
--if thefile exists in the folder localBrandFolder_PSD then do the result of dialog.
--"Skip" the file and move on to next
--If "replace" continue the rest of the script.
tell application "Adobe Photoshop CS5.1"
-- I remove the command activate, Photoshop stay in background
set ruler units of settings to pixel units
try
open (alias thefile) showing dialogs never
set origName to name of current document
set myOptions to {class:JPEG save options, quality:12}
set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
tell current document
--If the quick mask mode has been left on then delete the channel Quick Mask
if (quick mask mode) then delete channel ¬
"Quick Mask"
--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
if (exists layer "Original Layer") then ¬
tell layer "Original Layer" to set name to "Original Image"
save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
(delete layer "Original Image") flatten
resize image resolution 300 resample method none
--sharpen image
filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
save in (localBrandFolder_High_Res & name) as JPEG with options myOptions without copying
--get file path, return path of the JPEG file, work with (without copying)
-- (with copying) : it return path of PSD file
set newFile to file path --( return path of type alias )
-- duplicate file using the Finder -->on duplicateFile(..)
my duplicateFile(newFile, {ftpBrandFolder_High_Res})
--Prepare for Low RES by resetting image history
set current history state to history state 3
flatten
resize image width 1348
resize image resolution 300 resample method none
filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
--add save to lowResFolder with same options
save in (localBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
set newFile to file path
set newFile2 to newFile as string -- for testing end of name
if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" then -- exclude website_images
my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res})
else
my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res, website_images})
end if
close saving no
end tell
on error
set noError to false
my myLogs(thefile) -- write path to log file in Desktop
try
close saving no --if exists, close current document
end try
end try
end tell
end repeat
--End BH
-- else if and the rest of the script.....
end repeat
if not noError then do shell script "/usr/bin/open ~/Desktop/LogPhotoshopError.txt'"
on myLogs(t)
try
do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
end try
end myLogs
on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
tell application "Finder" to repeat with folderPath in foldersPath
with timeout of 200 seconds -- adjust it, error if the copy is longer that 200 seconds
duplicate tFile to folder folderPath with replacing
end timeout
end repeat
end duplicateFile
on getFolderPath(tName, folderPath)
tell application "Finder" to tell folder folderPath
if not (exists folder tName) then
return (make new folder at it with properties {name:tName}) as string
else
return (folder tName) as string
end if
end tell
end getFolderPath
tell application "Finder"
open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
end tellHi,
I think that's what you want.
I put the dialog in the beginning, so it does not appear to each folder, otherwise put it in the loop as it was originally.
property type_list : {"8BPS"}
property extension_list : {"psd"}
script o
property theseNames : {}
end script
-- empty log file
do shell script "echo 'Files not processed in Photoshop :' > ~/Desktop/LogPhotoshopError.txt"
set noError to true
--at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
--use the result for the if file exists?
display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
set skipFiles to (button returned of the result) is "Skip (Faster)"
--Setup list of folders and process details of folders
set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
set tc to (count dtF)
repeat with i from 1 to tc
set folderName to item i of dtF --<: is the folder name, no need to use text item delimiters -->":"
if folderName does not start with "2_" and folderName does not start with "Hot" and folderName does not start with "Press" and folderName does not start with "Design" and folderName does not start with "Keywords" and folderName does not start with "Season" and folderName does not start with "Sue" and folderName does not start with "Design" then
set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
set FolderEndName to last text item of folderName
set brandName to first text item of folderName
set my text item delimiters to "_PSD"
set weekNumber to first text item of FolderEndName
set my text item delimiters to oldTID
set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)
--set up names to destination folders and create locally based on brand name and week number
set this_local_folder to "Images:2012-2013"
set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
set this_Network_folder to "GEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
set website_images to "GEN:Website_Images:"
--set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
set this_ftp_folder to "pulse:"
set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
--taking the folder identify which process it must follow.
if brandName is equal to "BH" then
try
tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
on error
set o's theseNames to {} -- no psd files or "8BPS"
end try
set numOfNames to (count o's theseNames)
repeat with j from 1 to numOfNames
set thefile to theFolder & ":" & (item j of o's theseNames)
-- B H Folder Photoshop Process
tell application "Finder" to set b to exists file (localBrandFolder_PSD & item j of o's theseNames)
if b and not skipFiles then -- file exists and "replace" (continue the rest of the script).
tell application "Adobe Photoshop CS5.1"
-- I remove the command activate, Photoshop stay in background
set ruler units of settings to pixel units
try
open (alias thefile) showing dialogs never
set origName to name of current document
set myOptions to {class:JPEG save options, quality:12}
set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
tell current document
--If the quick mask mode has been left on then delete the channel Quick Mask
if (quick mask mode) then delete channel ¬
"Quick Mask"
--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
if (exists layer "Original Layer") then ¬
tell layer "Original Layer" to set name to "Original Image"
save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
(delete layer "Original Image") flatten
resize image resolution 300 resample method none
--sharpen image
filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
save in (localBrandFolder_High_Res & name) as JPEG with options myOptions without copying
--get file path, return path of the JPEG file, work with (without copying)
-- (with copying) : it return path of PSD file
set newFile to file path --( return path of type alias )
-- duplicate file using the Finder -->on duplicateFile(..)
my duplicateFile(newFile, {ftpBrandFolder_High_Res})
--Prepare for Low RES by resetting image history
set current history state to history state 3
flatten
resize image width 1348
resize image resolution 300 resample method none
filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
--add save to lowResFolder with same options
save in (localBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
set newFile to file path
set newFile2 to newFile as string -- for testing end of name
if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" then -- exclude website_images
my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res})
else
my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res, website_images})
end if
close saving no
end tell
on error
set noError to false
my myLogs(thefile) -- write path to log file in Desktop
try
close saving no --if exists, close current document
end try
end try
end tell
end if -- else "Skip" the file and move on to next
end repeat
--End BH
end if
end if
end repeat
if not noError then do shell script "/usr/bin/open ~/Desktop/LogPhotoshopError.txt'"
on myLogs(t)
try
do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
end try
end myLogs
on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
tell application "Finder" to repeat with folderPath in foldersPath
with timeout of 200 seconds -- adjust it, error if the copy is longer that 200 seconds
duplicate tFile to folder folderPath with replacing
end timeout
end repeat
end duplicateFile
on getFolderPath(tName, folderPath)
tell application "Finder" to tell folder folderPath
if not (exists folder tName) then
return (make new folder at it with properties {name:tName}) as string
else
return (folder tName) as string
end if
end tell
end getFolderPath
tell application "Finder"
open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
end tell -
Error while booting: SIOCADDRT: File Exists
I have a Toshiba laptop with two nics built in, one 100mb ethernet plug, one wireless. I do not use the wireless nic. When my laptop boots I get the "Starting Network" message then a [FAIL] with a "SIOCADDRT:: File Exists" error, however, the network starts and works fine. How can I go about clearing this error message?
Thanks.SIOCADDRT = Socket I/O Control Address Route F<something>.
Give that it tells you a file exist, I take it 'a file' means that there's some kind of route in place. Check if you have any routes defined in /etc/rc.conf or if any odd routes are defined in /proc/net/routes -
ORA-19870: error while restoring backup piece -- file exists in ASM
[oracle@rs1pre92dvdbsa01 ~]$ rman target sys/c9nv9sd9t9f11e@mdm11 auxiliary /
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Oct 29 10:41:38 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: MDM (DBID=1485385044)
connected to auxiliary database: MDM (not mounted)
RMAN> duplicate target database for standby;
Starting Duplicate Db at 29-OCT-10
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=13 device type=DISK
contents of Memory Script:
restore clone standby controlfile;
executing Memory Script
Starting restore at 29-OCT-10
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece +MDMDG2/mdm1/autobackup/2010_10_29/s_733654605.283.733654607
channel ORA_AUX_DISK_1: ORA-19870: error while restoring backup piece +MDMDG2/mdm1/autobackup/2010_10_29/s_733654605.283.733654607
ORA-19505: failed to identify file "+MDMDG2/mdm1/autobackup/2010_10_29/s_733654605.283.733654607"
ORA-17503: ksfdopn:2 Failed to open file +MDMDG2/mdm1/autobackup/2010_10_29/s_733654605.283.733654607
ORA-15012: ASM file '+MDMDG2/mdm1/autobackup/2010_10_29/s_733654605.283.733654607' does not exist
failover to previous backup
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 10/29/2010 10:42:00
RMAN-03015: error occurred in stored script Memory Script
RMAN-06026: some targets not found - aborting restore
RMAN-06024: no backup or copy of the control file found to restore
RMAN>
ASMCMD [+mdmdg2] > cd mdm1
ASMCMD [+mdmdg2/mdm1] > ls
CONTROLFILE/
FLASHBACK/
ONLINELOG/
arch/
autobackup/
ASMCMD [+mdmdg2/mdm1] > cd autobackup
ASMCMD [+mdmdg2/mdm1/autobackup] > ls
2010_10_29/
ASMCMD [+mdmdg2/mdm1/autobackup] > cd 2010_10_29
ASMCMD [+mdmdg2/mdm1/autobackup/2010_10_29] > ls
s_733654605.283.733654607
As seen in asmcmd "s_733654605.283.733654607" file exists in +mdmdg2/mdm1/autobackup/2010_10_29 then why it is complaning that it can't find the file.
and also How to open/view file in asmcmd[oracle@rs1pre91dvdbaa01 utl]$ sqlplus / as sysasm
SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 29 13:11:44 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup;
ORA-01078: failure in processing system parameters
ORA-29701: unable to connect to Cluster Synchronization Service
I have rebooted both the RAC servers and I can't start database?
I was under the impression that Database should be automatically started as part of Clusterware
Please help urgent. -
Hello Xperts,
I am working on Inventory Management.I am getting Error "No file Exists" when i do the initialisation of 2LIS_03_BF in the TCODE OLI1BW,I already deleted the Setup tables and 2lis_03_bx is successful.
I didn't lock any User,Is this error because of that,Can anybody Help me to solve this error.
And also Please give some TCODES to lock the users.
Thanking you,
With regards,
Stalin.When you run setup tyable fill in OLI1BW pay attention not to fill fields 'Archiving ID' or somethnig like that otherwise you'll get this error.
With transaction SU10 you can lock/unlock all users.
Hope it helps.
Regards -
Checking to see if files exist not working as expected.
Hey, so I've set up a script that determines the artist playing on iTunes and sets the background image to a preselected picture of them. I want to expand this to allow different pictures of the artists, and after a few attempts, decided to use a time based system. However, some artists have 2 images (named Artist1.jpg and Artist2.jpg), whilst others only have one (Artist.jpg). I can get the scripting right for if all artists have 2 images, yet am having problems with the system determining if certain files exist.
who is the artist playing, and myNum is either 1 or 2, and changes based on the time, both set earlier in the script and verified to work.
set MultiWall to ("/Users/ethan/Pictures/Music Wallpaper/" & who & myNum & ".jpg")
set SingleWall to ("/Users/ethan/Pictures/Music Wallpaper/" & who & ".jpg")
tell application "System Events"
if not (exists MultiWall) then
tell application "Finder"
set desktop picture to file SingleWall
end tell
else
tell application "Finder"
set desktop picture to file MultiWall
end tell
end if
end tell
I've tried many variations of this, from less variables to more, restructuring it and whatnot and it just isn't working for me. Thanks all.If you are still having difficulties you may like to try this method:
set myPath to "/Users/neville/Desktop/test" & ".png"
if (do shell script "/bin/test -e '" & myPath & "'; echo $?") is "0" then
tell application "Safari" to open myPath
end if
It should work if you copy and paste it.
Please note the combined single and double quotes. Don't put a space between them. You may not need the single quotes if you have control over the path. Most people would opt for 'quoted form of' but I prefer concise code. -
Check if files exist using ABAP
Hi All,
I'm currently using FM: FILE_GET_NAME_USING_PATH, and I'd like to do a check to see if the filepath with file (i.e. /com/tmp/file.txt) I am getting back exists or not.
Very simple question, just not sure what to do.
Thanks,
JohnThere is a class that provides methods to check, if a file exist or if a certain directory does exist
CALL METHOD cl_gui_frontend_services=>directory_exist
EXPORTING
directory = lv_path
RECEIVING
result = lv_valid
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = x_file_with_path
RECEIVING
result = y_file_exists
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
Hope that helps,
Michael
Maybe you are looking for
-
I have an older ipod...ever since I updated the itunes software my ipod no longer works in my car. my car is a 2013 mercedes E350. Is there a way to go back to an older version of the itunes software?
-
Exception while creating Employee Search Page
Hi all i have created a Employee Search Page by following some tutorials,now whenever i enter some values in the empno or ename fields and press GO i get the below exception Exception Details. oracle.apps.fnd.framework.OAException: oracle.jbo.RowCre
-
Hi, I have a variable block file which was transmitted from mainframe side. When i browse the variable block file in mainframe i can see it as !Line 1 !Line 2 !Line 3 but once we transmit the file in Unix box, the file contents appear as !Line1!Line2
-
Starting Inventory Management in BW
Hi experts, I am starting Inventory Management in BW and using the How to Guide. I understand how important the Stock init is and the need to block postings or to init during a period when no sotck movements occur. This is especially important for us
-
Problems after updating to ios7
I finally updated my iPad2 to the ios 7.0.4. I have tried to restore it from my itunes account and it goes through the process but after it is done and restarts, it takes me back to the setup again. Any suggestions on what to do?