Apple automator save as ### filename + extension selection - export

I'm trying to get some automator script going but I have no clue how to achieve it. It's like this:
in Processing I exported a batch of 1850 SVG's. These SVG's now have to be opened in an application called Cenon. This application can save SVG's as .hpgl files.
It's no problem to open a file in a specific application like Cenon when it's added to a folder. That works fine.
But how do I save this file in a specific extension like .hpgl and create a variable name? Because Cenon always opens a file with the name 'UNTITLED'.
So I need to do:
automatically open file one by one in Cenon
save file as .hpgl file
save file with variable name like (0001, 0002, 0003, 0004, 0005, etc.)
I hope someone can help me!!
Thanks in advance,
Fons.

First of all, let me make a distinction between two related technologies:
AppleEvents which are messages that can be used for different applications to communicate with each other, asking each other to do tasks.
AppleScript which is one kind of scripting language that can send and receive AppleEvents to and from Mac applications.
You can't use AppleEvents with Cenon but you still may be able to use AppleScript with Cenon. I know that you can't use AppleEvents with Cenon because I downloaded Cenon version 4.0.1 from the web and I tried to open up it's AppleEvent dictionary with the "AppleScript Editor.app" application that comes with OS X.
So, AppleEvents are out. This means the "tell" command in AppleScript can't tell the Cenon.app to do anything with AppleEvents, but you may still be able to use AppleScript.
AppleScript can be used by simulating user menu-selections and key strokes instead of using AppleEvents. Using AppleEvents would be better, but sometimes, using AppleScript, you have to go through the user interface.
An alternative to resorting to using AppleScript to simulate the user-interface (UI) would be to use a shell-command. It just seems to me that this would be a better solution, but you would have to find a Unix shell command that was compiled for Mac that would convert from .svg to .hpgl
If you really want to use AppleScript and Cenon.app, here is a link to study about using AppleScript going through the UI of an app:
http://www.macosxautomation.com/applescript/uiscripting/
AppleScript was originally designed to be a scripting language to take some of the functionality with application A, and then take some of the functionality of application B, etc, and glue it together with a little logic from AppleScript and empower the user to more easily automate their tasks.
AppleScript was designed to be an alternate user-interface, going through AppleEvents, but AppleEvents are not as widely supported as they could be by applications, so this kludgy solution of having AppleScript go through the GUI is commonly done.
Again, I think that a shell script would be a better solution for this problem and you could call is "solution.command" or you could embed the shell script into an Automator Workflow saved as an Application or embed the shell script within an AppleScript saved as an application. Either one work work.

Related

How to lock an exe file?

(Sorry in advance, if I have the wrong tags)
Hello!
So I am trying to work on a personal WPF project which would allow the client application exe to download another application exe (Unity Application) and open it within the client exe's Grid. Everything is working fine.
But, I am wondering if there's a way to "lock" the downloaded application in a way that only my client exe can open the downloaded exe?
Here's the only solution I have thought of but not sure with
Check for command line arguments within the Unity Applications
This works well but people who knows about the existence of decompiler might be able to decode that I am trying to check the arguments, and input relevant data there. :(. So, it won't help too much?
Thanks for any insights.
-Kevin
There is no non-hackable solution, you can only make it harder for crackers to break into the app by code obfuscation (hard to read the code) + adding integrity checks (make sure that your app is not modified).. There are commecial apps out there to do this (ex. PreEmptive), and their solutions differ from each other, nothing is ultimate.
Anyway, You might make Unity Application read some file or some registry value that Client application has updated just before launching the Unity Application, along with command line args method that you mentioned..

How to use shp2pgsql

My question should be very simple to answer for anyone not being a self-taught newbie like me...
On this page is a cheatsheet concerning a function to be used in GIS/DB environnement : http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide.bqg
I would like to create a script allowing users to just have to click on it to launch the process, given the proper datas. But I don't understand how to use this. It obviously doesn't work in a Python console, nor directly in the windows console. How is it supposed to work ? What language is this ?
Thanks
shp2pgsql is indeed a command line tool. It comes with your PostgreSQL/PostGIS installation (usually) and, if not accessible via PATH-variable, can (usually) be run from within the /bin-folder in your PostgreSQL-Installation. You can also always 'make' the programm from source in any location yourself, if needed.
EDIT:
One way to set up a script (independent of whether you use it within qgis own python environment or not) would be to use Pythons subprocess (or os.system) module (check related question here) to write to shell and execute shp2pgsql.
A slightly more sophisitcated solution to (batch) insert (multiple) shapefiles via script could be to implement ogr2ogr via gdal/ogr module within python (check this blog). That, however, would require a working installation of the gdal core library, and the respective Python bindings (at least to use outside of QGIS Python environment, where it is pre-installed AFAIK), which can be tiresome at times. Once installed correctly, it offers a powerful (I dare say almighty) toolset for geodata management and manipulation via Python, though.
Apart from that, the blog link I provided also states the implementation of a batch insert script/tool (which operates ogr2ogr) in qgis 2.8 toolbox...maybe that can help you, either with your work directly or (via sourcecode) to point you in the direction of creating your own tool.

Can I batch file upload videos on YouTube?

Recently, I've found myself doing a very long but repeated process of editing and uploading certain kind of videos online on YouTube. My friend suggested to write a batch file or a script as he said to help with the process, so I've decided to learn how to write it.
But first is that even possible? to write script file that open certain programs and do certain processes. And might open browser and click on certain buttons and make that?
Check out Youtube-upload
It's a command-line Python script that uploads videos to YouTube. It should work on any platform (OS X, Windows, etc) that runs Python. It is using the YouTube API V3.
If you are looking to automate the operation of Windows software. Look into AutoIt which provides a GUI and a simple basic-like scripting language to do so.

Run GUI from batch file is unprofessional?

I recently released a software to our customer, it will be installed on one machine at one location and maybe later at two other locations. It is a prototype and has to be tested.
This is a compiled Matlab GUI which runs scanning, does some image analysis and produces report. All is fine here. But I've got a complaint that batch-file I use is a thing from past DOS times, should not be used and looks unprofessional... Currently, the user should set up one path in batch file before the first use and then always run batch file. This bat-file kills some processes to avoid conflicts, including any running instances of the GUI, sets the path for results and runs the GUI. I proposed them to create a shortcut to this bat-file with a nice logo (such that they don't see the .bat extension ;)), but they are still unhappy.
What to do is probably not the main question here - client is always right and I should remove .bat somehow to make them happy. But is it really so unprofessional to release technical, not mass software using bat-files? Or is it just one person's opinion?
Personally I think if you already have a GUI, then use that to do the pre-processing. There is nothing wrong with using batch files, but using one when you have a GUI doesn't seem like the best way to do it.
Alternatively create a GUI with the same look as the main program to ask the user for the details it needs. For me it's not about professionalism, but how easy it is for the user to do what they need to do.
I see nothing wrong with using a batch file for small projects (especially during the testing phase if that is easier for you and delivers something to the client quicker). However, depending on the size of the project, it is nice to have an EXE to deliver to the client with a proper icon and what not.
I would agree with the customer that an EXE looks more professional. Whether it is or not... I'm not sure. The .bat files just seem a little slapped together whether that is true or not.
I would say this is similar to when people call PHP programs scripts because a lot of the times they are simple scirpts. But, then there are frameworks out there like Cake and Kohanna that are more than what someone would typically classify as a script but, since it's PHP there is still that connotation.
A batch file is not unprofessional. The batch "language" has disadvantages and outright problems (error handling!!) but it gets the job done and that's the point.
The problem is that it shows the internals of the program and some people are scared by this. They don't want to see anything like this and so try to find a disapproving label. The quickest solution is to hide the batch file behind a "vanity cover", or in this case an exe that hides the working from terrified eyes.
One simple possibility is to use an self-extracting zip file eg: http://www.7zsfx.info/en/

Execute a program with a custom .ini path

I make a fair amount portable Apps for personal use and they work perfectly for the most part. I do, however, find it quite frustrating that if I run them on another computer none of my preferences are retained, as a program always looks in appData for the configuration files (which obviously don't exist on another system), so I'm wondering whether there is some kind of command line to launch an .exe with a custom .ini location.
I'm asking this firstly because Google has proved fruitless (once again) and secondly because I know it's possible - I've actually done this before, but with only one of my Apps. I accomplished this by launching the App via the command programFile.exe -f configFile.ini /s (I have also seen programFile.exe -d -f configFile.ini /s elsewhere). Naturally, I thought I would try to apply this to some other Apps but it seems it only works for that particular App.
So, is there a command/switch that I am unaware of that will do this for an .exe file?
Thanks
It really depends on each executable file you are using. Some have support for what you are looking for, and some don't. Some programs don't even use .ini files. What you should look for is if each and every program you use have support for user data custom location.
Edit
The only case where generic arguments would be avaialble for a group of EXE files is if they are generated with the same tool, which automatically provides these arguments for you. InstallShield and MSI install programs have that kind of feature (with the silent install and automated installation for instance).
I suggest you look into the tool you are using to generate your portable Apps, and see if it does provide those generic arguments for you, and how they work. If it does not have that feature, then look into the Apps you were able to specify a custom location for your INI file. Somewhere into the code, there must be a piece of code that handles the arguments you specify to the EXE file and handles them. You should share that piece of code with your other Apps, to make sure they provide the same arguments list.

Resources