Append multiple PDF files - pdf

I have about 600 PDF files that I want to add a single disclaimer page to the beginning of each of them. So, I need to find a way to merge two PDF documents where one file is always the same and and comes first and the second file is changing.
Please let me know how I can do this.
Thanks!

I found this:
http://gotofritz.net/blog/howto/joining-pdf-files-in-os-x-from-the-command-line/
So you could do something like this in a shell script:
#!/bin/bash
page1="disclaimer.pdf"
for f in {a.pdf b.pdf c.pdf}; do
"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" -o "$f" "$page1" "$f"
done
You can wrap this in an Applescript or automator workflow it you like.

Combine an unknown PDF with a known PDF
Automator can do this. You would save it as an application, so that you can drop the second file onto it. Your steps would be something like:
Get Specified Finder Items: Add the known PDF document here, the one that is “always the same and comes first”.
Combine PDF Pages
Move Finder Items: To: Combined Files. This will create a randomly-named file in the folder “Combined Files” which you will need to create.
If this Automator workflow is saved as an application, you can drop your second, "changing" file onto the application icon. The workflow will combine the two, putting the named file first.
Loop this workflow for each dropped file
In order to do this on multiple files at once, you will need to create a second workflow that loops through each dropped file and calls the above workflow. This second workflow is also created as an application. It has only one step:
Run Workflow: choose the workflow created in the previous step, and process items in batches of 1 at a time using 1 workflow.
Give the files a more usable name
That’s the basics. The obvious drawback is that all of the files have random names. That can be fixed by grabbing the original filename into a variable, and saving the new, combined document using that name in your new folder.
First, add four new steps to the top of the first workflow, in front of “Get Specified Finder Items”:
Run AppleScript
Set Value of Variable: name the variable filepath.
Run AppleScript
Set Value of Variable: name the variable filename.
Get Value of Variable: filepath
The first two steps save the full path to the dropped PDF. The second two steps get just the filename portion. The fifth new step pops the full path back into the workflow so that it can be combined with the known disclaimer.
Set the AppleScript in step 1 to:
on run {input, parameters}
return input
end run
Set the AppleScript in step 3 to:
on run {input, parameters}
tell application "Finder"
set filename to name of file input
end tell
end run
Then, add a step at the end to rename the file. After Move Finder Items add *Rename Finder Items. Choose “Name Single Item”, “Full name to” and then drag the variable filename up to the text box.

Related

pentaho spoon/pid: how to move files to folders with different name everytime?

I have new text files every month from where I extract the data and do some transformations. In the end of every month, I need to move these files to a folder with current date in name. Which means, the destination folder's name is different everytime.
I made a step before move files that creates a folder and its name is current date (exp: 2019-06-01, 2019-07-01), but then on move files step, I don't know how to specify the destination folder. Guess "wildcard" is only used for source...
Otherwise, on move files - Destination file - Move to folder, there is create folder option, thought it could be a solution but as on the screenshot, this section can't be modified. What is the reason?
Does anyone have an idea ?
Thanks for reading :))
You can utilize this approach for this task.
Basically you'll have to extract the date you want from each file before doing the transformations, and after all the transformations are done, you'll use the JOB step 'Move files', but instead of passing a fixed destination, you'll use variables in the path, much like this answer, but you don't need to create the folder before, you can just use the option on the 'Move files' step, so the folders are created at run time.
I have attached an example of this approach with some commentary in the KTR/KJB.
You can download here
Let me know if the link is working, this is my first time posting an external file in StackOverflow

Check if file exists in folder or not (SSIS, SDT 2015 and SQL 2016)

I need to load multiple files into a SQL table. I have three different formats, CSV, XLSX and XLS, but I will load one type of files at a time, no combination of different file types.
First, I will check in my source folder if the file exists or not. If it exists, load it to table and move to next file. The file checking and selection process must be dynamic. I don't want to hard code the file name in a variable. When the package starts, I need the filename variable to hold the very first file present in the folder each time when I run the package.
If the file is not found in the folder, send mail alert that file doesn't exist.
For example, if I have three files in my folder,
File1.csv
File2.csv
File3.csv
I run my package and I hard code the file name variable = File1.csv in the first run. My package gets executed successfully and loads the file1 to the table and archives it to the archive folder.
When next time for each loop runs, it looks for variable filename = File1, but it's already archived, so my package will not able to process file2 from the folder. How can I do this properly?
First use a script task to check if any file is present in the folder or not.Create an integer variable and set it to 1, if file is found and to 0 if file not found. Use expression and constraint in the precedence constraint.
http://www.techbrothersit.com/2013/07/ssis-how-to-check-if-file-exists-in.html
If evaluation expression is false,connect it to a mail task,else
connect to a for each loop task.
Please refer:https://www.simple-talk.com/sql/ssis/ssis-basics-introducing-the-foreach-loop-container/ or more details.
A trick in SSIS is to create a Foreach Loop.
Create a Variable containing the path where the file resides. Example User::filepath
Create another variable to save the actual file found on the Foreach loop, example User::filename
Add the Foreach Loop from the SSIS Toolbox.
On the Foreach Loop editor, on Collection left tab select in Enumerator - Foreach File Enumerator
Click Expressions and add one for Property Directory and select in the expression the #[User::filepath]
Enter on the Folder the value of the filepath variable (this will be overridden at execution from the Expression above, this is if you filepath is changed at runtime)
On file enter something like . or *.txt or whatever filter you want to apply to the folder.
On the Variable Mappings left tab select on the Variable column the User::filename variable, the Index column will default to 0.
Then put your logic inside the Foreach Loop box.
This will only execute your logic if a file is found. You can also use this to process multiple files if they exist on the folder.
Hope this helps.
The problem with Foreach Loop Container is it will not process any task within the container but will continue outside of it.
A solution is an expression on the constraint to the next task.
enter image description here
It will check the variable length used in the Foreach Loop Container. If a file isn't present, the expression will return 0 and FALSE.
LEN(#[User::filePath]) > 0 ? TRUE:FALSE
filePath = Foreach Lop Container variable
enter image description here

Creating a file with name given in code in LiveCode

I'm trying to build a program that gets users name at first. This user names are kept in a text file. After user logins, according to the user's name, I want user to be lead his/her specific informations. I figured out that I can only do it with a file that is created when he sign up for an account which I direct him with my sign up button in Livecode. While he/she create his account I want to create a specific file for his/her. Can you help me with it please?
PS: I don't want to do it with a database right now. I just want to learn how to create a file without a specific name like
put specialFolderPath("documents")&"/userLoginCridentials.txt" into tFile put URL("file:"&tFile) into myFile
Instead of this "userCridentials.txt" I want something user can create with his own name :)
Having a little problem to understand your question. Are you targeting mobile or desktop? Are you having problem saving or reading the data?
If saving is you problem
On desktop you can use:
ask file "Save file as:"
then you get the filename back in it so you can use:
if it is not empty then
# We have a complete file path in 'it'
put it into tFile
put tData into url ("file:" & tFile)
end if
If you targeting mobile and would like to save into the specialFolderPath("Documents")you can get the filename from a field and then save to that file. E.g. if you have a field named 'fileName' you can use something like:
put tData into url("file:" & specialFolderPath("Documents") & "/" & field "fileName"
Of course you should do some error checking to ensure that a user don't overwrite existing files without at least asking for permission, etc.
You can of course use a variable instead of a field...
If reading data is your problem
On desktop you can use:
answer file "Open File:"
Same as above but you now read data instead:
if it is not empty then
# We have a complete file path in 'it'
put it into tFile
put url ("file:" & tFile) into tData
end if
on mobile you probably would like to present a list with the user-created files. In LiveCode you can list all files in the defaultFolder with the files. But you must set the defaultFolder to the folder you want to list.
set the defaultFolder to specialFolderPath("Documents")
put the files into tFiles
Now tFiles contains every file in that folder and you can filter it, display it in a list etc. E.g:
filter tFiles with "*.txt"
put tFiles into
If your problem is how to remember the "current" file name
Whenever you restart your app every variable is reset. So everything you want to remember between runs needs to be saved before your app quits. And for that you need a predefined filename. SO then your procedure will be:
Read in the predefined file.
Grab the file name from within that file
Read the file
If your problem is something else
Sorry, then I misunderstood your question...

assignging text file contents to variable

Stack!
I'm currently trying to code a neat little function in Visual Basic that deletes my entire file system for my program depending on the contents of one text file.
If my text file contains the number 0 by itself, my file system will be deleted. If it contains a 1 by itself, it will not delete the file system and carry on with its pathway of execution.
the problem I'm having is reading the file, then assigning the text file's contents to a variable (string), which then is used in an if statement to decide whether it deletes (then immediately recreates) the file system, or keeps it. Ideally I'd be using this primarily for when the user installs. By default, it is set to 0 so that it clears any stored content, then after creating my directory, the number turns to 1 so that it does not reset my programs content directory.
Here's my code. The first line is giving me difficulties -
Could not find file 'C:\Users\110fa_000\documents\visual studio 2013\Projects\Novation_Launchpad_Emulator\Novation_Launchpad_Emulator\bin\Debug\0'.
fileReader = File.ReadAllText(My.Resources.FirstTimeUse)
If fileReader = "0" Then
FirstTimeUse = True
End If
If you can help me, that'd be absolutely brilliant. I don't think there's any more information I can give sadly, but everything regarding the function, purpose, and error is there.

document migration name extraction

I have a scenario and would like to see if anyone has any suggestions on how I should tackle it. Basically I have a directory full of files, document names consist of [Code]-[number]-[text]
CODE - A generic 3 letter code.
NUMBER - a number generally 4 - 5 digits in size.
TEXT - original document name (Before it was dumped).
CODE, NUMBER and TEXT are separated by a colon (-). Number always starts at the 5 character.
I would like to somehow scan that directory and extract the number from the filename, I would then like to compare that number to a field in a database (SQL query fairly straight forward, could also extract as raw text) If the number matches the number in the database I would like to separate those files.
If I need to clarify anything please ask. I wasn't sure if this site is appropriate for my query.
Open the root folder, click in the file explorer path (in open space off to the side so the whole path gets highlighted), type cmd and hit enter to open a command prompt from that folder location.
Type: dir /b /s > filelist.txt to get a list of all file names. You can exclude /s if you don't need/want to dig down into subfolders.
I'd paste that into excel, if you have 2013 you can just start typing the part you want to extract, after you type the full first line when you start typing the next line it will recognize the pattern and you can just hit enter to fill down.
Otherwise, use Data > Text to Columns and specify - as a delimiter.
Likewise you could just import the filelist, separate them in SQL using SUBSTRING() or similar. When you have your matching filenames you can just use some concatenation to build a COPY or MOVE .bat file, pretty easy in SQL or Excel.