Make "NEW" folder in Photoshop script - photoshop

A'm having trouble making a folder.
The scrip has its original folder like so: doc.exportDocument(File(doc.path+'/'+newName),ExportType.SAVEFORWEB,options);
but I'm trying to put the images in a named "NEW" folder within the image path like so" doc.path+'/New/'+newName
but no luck.
i tried making the folder right before the save like so:
var f = new Folder('doc.path+/New/');
if (!f.exists)
f.create();
but still the program tells me there is no such location. How can i make that folder?
thank you so much.
#l3ny

var f = new Folder(doc.path + "/New/");

Related

How to check for any files with FileExists(String) method

I'm trying to automate a document handling process, and I need to check if there are any files inside a certain folder. The process itself removes the files from the folder once it finishes, so I need it to loop back and check if there are any files left.
So far I've been using a sample file like this:
File.Exists("C:\Users\gcaor\Desktop\OC\150.pdf")
150.pdf is the sample file it's searching for, but is there a way to search for any file at all? So that it returns true if there is a file in the folder and false if there isn't
You can use Directory.EnumerateFiles + Any:
Dim anyFileExist = Directory.EnumerateFiles(path).Any()
This is using standard .NET methods and also stops at the first file found.

File Path of Access Database

I'm working with vb.net 2008 as well. But I have a question.How to remove a file path like this C:\users\myDocu\debug\Dbase.accdb and I only want is the file name Dbase.accdb. Because I want to transfer my files in another computer but the problem is the file path. I always need to change the entire location in my codes to run without debug.
To get the filename without the path, you can use Path.GetFileName.
But if you want a painless way to find a place to store your database, consider putting it into the application data folder (AppData). You can get this folder with Environment.GetFolderPath and Environment.SpecialFolder.ApplicationData, using it like this:
Dim pathToDb = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"Dbase.accdb")
if you want to use the file locally. If you want to share the file between different instances of your application in a network, put the path e.g. in a config file like App.Config.
Try this:
Dim FullFilePath As String
Dim FileName As String
FullFilePath = "C:\users\myDocu\debug\Dbase.accdb"
FileName = Mid(FullFilePath,InStrRev(FullFilePath,"\") + 1)

Reference a file in Unit Test (VB.Net 2012)

I'm really puzzled on this one.
I an writing unit tests for a project. I need to open and use a file for the testing. I am developing in two environments (work and home) and am using Dropbox to keep my code to be able to use the most recent version at either place.
I have created the test file and have placed it in a folder in the Unit Test project. I could obviously use the file spec
c:\blah\blah\blah\file.txt
but that would only work on one machine.
So my question is...
Is there a value/parameter/Constant that I could use in my test code that would have the root of the project regardless of which location I am at. I want to be able to reference the file like so:
{projectRoot}\folder\file.txt
You can get the path to the folder in which the current executable resides, like this:
Dim exeFolderPath As String = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
Or:
Dim exeFolderPath As String = Path.GetDirectoryName(Environment.GetCommandLineArgs()(0))
Or, if you are in a DLL, and you need to get the path to the folder containing that DLL, instead of the executable that is using it, you can do this:
Dim assemblyFolderPath As String = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
Alternatively, you can just use the current folder, like this:
Dim currentFolderPath As String = Directory.GetCurrentDirectory()
Then you can drill down to a sub-folder, like this:
Dim subFolderPath = Path.Combine(exeFolderPath, subFolderName)
In order to make it so that the text file, which is included in your project, exists in the output binary folder, just select the file in the Solution Explorer, go to the properties window and change the Copy to Output Directory setting to either Copy always or Copy if newer. Then, when you build your project, the file will automatically get copied to the appropriate bin folder.

Download to root directory

Okay, so I have been searching for ages to find this but no luck.
I am using:
Me.downloader.DownloadFileAsync(New Uri(fileUrl), Path.GetFileName(fileUrl), Stopwatch.StartNew)
To download a file but I want it to save to the root directory of my program in a file called launcher.
So for example, if my program is on the desktop and I open it and click start I want it to create the launcher folder if it's missing then download the files into that and if it's not then just download the files into it.
I've been looking everywhere to find code which would allow me to do this and I have tried lots of different things.
At the moment, it justs saves in the root directory of where the program is.
Thanks.
Try something like this:
Dim baseDir As String = AppDomain.CurrentDomain.BaseDirectory
Dim launcherDir As String = Path.Combine(baseDir, "Launcher")
If Not Directory.Exists(launcherDir) Then
Directory.CreateDirectory(launcherDir)
End If
Dim targetFile = Path.Combine(launcherDir, Path.GetFileName(fileUrl))
Me.downloader.DownloadFileAsync(New Uri(fileUrl), targetFile, Stopwatch.StartNew)

How to use Process.Start

I'm using process.Start to run Convert.exe. This program's purpose is to convert all files which are in the exe's folder. So when I normally use it, I copy paste a file into the same folder as Convert.exe and then run Convert.exe. Convert.exe will create a new "converted" file in the same folder.
I'm trying to automate this tedious process. A User selects a file which needs to be converted from FolderA, I copy it to the same folder where Convert.exe is and I'm using process.start(Convert.exe) to run it.
Just to be clear, this "Convert.exe" accepts NO arguments.
The problem: "Convert.exe" is not converting the files in its folder. Instead it's converting all the files in FolderA for some weird reason. I don't know why it picked that folder, I never even try to send it as an argument or nothing.
Here's the code I have:
Dim techInfo As New System.IO.FileInfo(itm.strFilePath)
techInfo.CopyTo(ConverterPath & techInfo.Name)
Dim procInfoConvert As New ProcessStartInfo
procInfoConvert.CreateNoWindow = False
procInfoConvert.Arguments = ""
procInfoConvert.FileName = ConverterPath & "Convert.exe"
Dim procConvert As Process = Process.Start(procInfoConvert)
I did a test where I copy pasted a file into the "Convert.exe" folder and then just run this code:
process.start(ConverterPath & "Convert.exe")
The exe returns nothing, same as if there was no files in the folder.
The only thing I can think of is that when process.Start is run, it copies the file to another location and runs it from there.
Any ideas anyone?
Try this:
procInfoConvert.WorkingDirectory = ConverterPath
That'll set the process up to start in the directory it's contained in, instead of the current directory.