Force jdownloader to name the file for any url without setting the name manually in UI - jdownloader

I have a url & I want jdownloader to save the file with a predefined name ignoring the name server gives
for example
I have a url like http://server.com/server-file.mp4 & I want this file to be saved as custom-filename.mp4 without using UI
Is it possible to pass a special URL argument to the download URL so that jDownloader can recognise this & save the file with this specific name?
For e.g for the above case, can I paste something like the following url in jdownloader
http://server.com/server-file.mp4?jdSaveAs=custom-filename.mp4 so that jdownloader automatically saves this file as custom-filename.mp4 instead?

You can append the custom file name to the URL and parse it using packagizer rule.
Rewrite URL in this format:
https://board.jdownloader.org/server-file.mp4#filename=custom-filename.mp4
filename download: custom-filename.mp4
Import this rule in Packagizer (Right-click the 'Raw' button to save file to disk)
https://gist.github.com/rodrigolmacedo/231a7692ace1b0cbf6aa7dc82d0e665a
original post outdated
<jd:append>
-> this placeholder will be replaced by previous value where the placeholder is being used in
<jd:prop:KEY>
-> this placeholder reads out an internal property of the downloadlink itself. properties are plugin specific and there are plans that plugins can return a list of supported properties that can be used here
<jd:indexof>
-> this placeholder will be replaced by number of index of the downloadlink within its package. first link will be 1, second link will be 2 and so on. It's just the index within the package!
-> will be replaced in real time
<jd:subfolderbyplugin>
-> some plugins support recursive folder support. if supported by plugin, then the downloads will have same directory structure like shown in browser
<jd:env:KEY>
-> this placeholder will be replaced by KEY environment variable of your system
-> will be replaced in real time
<jd:orgfilename> <jd:orgfilename:number>
-> this placeholder will be replaced by original filename or matching group(number) of filename pattern
<jd:packagename>
-> this placeholder will be replaced by the current package name
-> will be replaced in real time
<jd:orgfiletype> <jd:orgfiletype:Pattern>
-> this placeholder will be replaced by the file extension of the file or the match of the given pattern
<jd:orgfilenamewithoutext>
-> this placeholder will be replaced by original filename without file extension
<jd:hoster:number>
-> this placeholder will be replaced by the matching group(number) of downloadurl pattern or the host itself if number is -1
<jd:source:(number)pattern>
-> this placeholder will be replaced by the match of sourceurl pattern. with number you can specify which sourceurl to process
<jd:simpledate:simpleDateFormatString>
-> this placeholder will be replaced by time formatted with simpleDateFormatString, see docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
-> will be replaced in real time
<jd:orgpackagename>
-> this placeholder will be replaced by the original package name ```
https://board.jdownloader.org/showthread.php?p=421993

Related

AHK: How to store a selected file in a variable to execute an script using FileSelectFile function after selected in Window/File explorer?

Apologies, I am quite new with AHK.
Context: I am trying to build a small program (eventually with UI) which will clean data in .XLF files in order to be processed properly by a CAT tool interpreter (import into it).
By "clean" I mean to find HTML attributes and replace them with their respective Char Entities. This as a single script; writing the name of the file or path inside the script is working perfectly.
Problem: I would like to run my .ahk/.exe allowing the user to open the file manager/explorer and select the file that needs to be processed by the script (find/replace html attributes with char entities) selecting the file is not working. Nothing is populated (the final file/result is empty) I'm trying to sort out this with FileSelectFile function and store the output var value (selecting the file) in the first instruction "fileread, selectedfile".
But it's not working! If I don't do this and I only provide in the default directory "A_ScriptDir" an specific file name .xf -> this works fine.
This is my code so far w/comments:
SetWorkingDir, %A_ScriptDir%
FileEncoding, UTF-8
;NoEnv
;Open Window File Manager/Explorer and select a file .xlf file
FileSelectFile, SelectedFile, 8, , Open a file, , ,(*.xlf)
;--- > HTML attribute '&' must be replaced by its char entity first/overall otherwise this instruction will overwrite the amp entities from the rest of char entities corrupting the file;
;"SelectedFile" can be any filename such as "example.xlf" but this is not my scope
fileread, text, SelectedFile ;previously "text.xlf" with random html content to do tests
replace := "&"
newtext := strreplace(text, "&", replace, all)
sleep, 200
filedelete, newtest.xlf
fileappend, %newtext%, newtest.xlf
;--------------------------------- <b>
;here "fileread" must read the final appended file as solution to use "streplace" function multiple times (replace more than one desired string) running the script at the same time. (due to my lack of exp. with loop function)
fileread, text, newtest.xlf
replace := ">b<"
newtext := strreplace(text, "<b>", replace, all)
filedelete, newtest.xlf
fileappend, %newtext%, newtest.xlf
I've been thinking that other solution can be:
I am still new to understand apply Drag and Drop GUI but I am unsure how to modify my code in order to drag/drop a file onto the ahk.exe
Thanks for your time reading this! any tip and/or help would be super appreciated :)
The FileRead command expects text, not an input variable.
So if you add % around SelectedFile like this, it should work:
FileRead, text, %SelectedFile%
If that doesn't work, it means the file does not exist or an error occurred. In that, you'll want to look at FileRead's error handling section.

Youtube-dl 'outtmpl' dynamic output

I'm trying to create a python program that allows you to dynamically choose the folder to save the download.
'outtmpl' lets you choose an output as a simple path such that
'e:/python/downloadedsongs/%(title)s.%(ext)s'
is a valid path and will let you save to the downloadedsongs folder
But With the function that defines the choose folder button
def openLocation():
global Folder_Name
Folder_Name = filedialog.askdirectory()
print(Folder_Name)
why does
f'{Folder_name}/%(title)s.%(ext)s'
not return a valid path, the program outright ignores the variable. I thought at first i was having a fstring issue because %s was pythons old format for f'strings but I have also tried these variances with no success
'outtmpl': Folder_Name + '/' + '%(title)s.%(ext)s', (no errors but cannot find output)
'outtmpl': '%(Folder_Name)s%(title)s.%(ext)s',
%()s is the old version of fstrings I was conflating the two.
answer ended up looking like 'outtmpl': Folder + '/%(title)s.%(ext)s'

Renaming a file source

I've been developing an SSIS package from a flat file source. The file comes daily and the file name has datetime indication like this:
Filename_20190509042908.txt
I was wondering how I can pass until the date part; I want the package to read the file dynamically, but it should pass without the last 6 digits I just don't need the last 6 digit numbers as it is not consistent.
I want to pass Filename_20190509.txt
I have figured out how to take the filename until date removing the time part. Hence, I've trouble to let the package read the file name dynamically by ignoring the last 6 digits before file extension.
Can anyone help me with this please?
Remove the time part from the full file path
Assuming that the full file path is stored within a variable named #[User::FilePath]
You have to add a variable of type string (example: #[User::Filename]), Before the data flow task add an Expression Task and use the following expression:
#[User::Filename] = SUBSTRING(#[User::FilePath], 1, LEN(#[User::FilePath]) -
FINDSTRING(REVERSE(#[User::FilePath]), "\\", 1)) + "\\" +
LEFT(TOKEN(#[User::FilePath],"\\",TOKENCOUNT(#[User::FilePath],"\\")),
LEN(TOKEN(#[User::FilePath],"\\",TOKENCOUNT(#[User::FilePath],"\\"))) - 10) + ".txt"
Example:
If the value of #[User::FilePath] is
C:\New Folder\1\Filename_20190503001221.txt
Then #[User::Filename] will be:
C:\New Folder\1\Filename_20190503.txt
If You have only the file name as
filename_20190503001221.txt
and the folder path is stored in another variable, just use the following expression:
#[User::Filename] = #[User::Folderpath] + "\\" +
LEFT(TOKEN(#[User::FilePath],"\\",TOKENCOUNT(#[User::FilePath],"\\")),
LEN(TOKEN(#[User::FilePath],"\\",TOKENCOUNT(#[User::FilePath],"\\"))) - 10) + ".txt"
Read File Source from Variable
Click on the flat file connection manager used to read the source file, press F4 to show the properties tab, Click on the expression property and assign the following expression to the connectionstring property:
#[User::Filename]
Now change the Data Flow Task Delay validation property value to True.
Dynamic Flat File Connections in SQL Server Integration Services
I have to assume you are using a foreach loop already as the filename is changing but here is how to change the fully qualified name to what you want:
TOKEN(character_expression, delimiter_string, occurrence)
Your usage:
this will get you the full filename:
exp = TOKEN(#filename,"\",LEN(#filename)-LEN(replace(#filename,"\",""))
then from there you need use left plus add .txt
left(exp,LEN(exp)-10) + ".txt"

Current file path in Live Template

Is it possible to get the full path of the current file within a live template in IntelliJ? I've tried using groovyScript("new File('.').absolutePath") function, but that returns /Applications/IntelliJ IDEA.app/Contents/bin/. and not the file path as I was hoping for.
Thanks!
According to the docs (emphasis mine):
You can use groovyScript macro with multiple arguments. The first argument is a script text that is executed or a path to the file that contains a script. The next arguments are bound to _1, _2, _3, ..._n variables that are available inside your script. Also, _editor variable is available inside the script. This variable is bound to the current editor.
The _editor is an instance of EditorImpl which holds a reference to the VirtualFile that represents the currently opened file.
Therefore, the following script gets the full path of currently opened file.
groovyScript("_editor.getVirtualFile().getPath()")
Or if you want to get the path relative to the project's root:
groovyScript("_editor.getVirtualFile().getPath().replace(_editor.getProject().getBaseDir().getPath(), \"\")")
Since IntelliJ IDEA 2019.3 the Live Template macros filePath() and fileRelativePath() are available. A complicated Groovy script macro is no longer required.

CFSCRIPT - How to check the length of a filename before uploading

I ran into this problem when uploading a file with a super long name - my database field was only set to 50 characters. Since then, I have increased my database field length, but I'd like to have a way to check the length of the filename before uploading. Below is my code. The validation returns '85' as the character length. And it returns the same count for every different file I upload (none of which have a file name length of 85).
<cfscript>
missing_info = "<p>There was a slight problem with your submission. The following are required or invalid:</p><ul>";
// Check the length of the file name for our database field
if ( len(Form["ResumeFile1"]) gt 100 )
{
missing_info = missing_info & "<li>'Resume File 1' is invalid. Character length must be less than 100. Current count is " & len(Form["ResumeFile1"]) & ".</li>";
validation_error = true;
ResumeFileInvalidMarker = true;
}
</cfscript>
Anyone see anything wrong with this?
Thanks!
http://www.cfquickdocs.com/cf9/#cffile.upload
After you upload the file, the variable "clientFileName" will give you the name of the uploaded file, without a file extension.
The only way to read the filename before you upload it would be to use JavaScript to read and parse the value (file path) in the file field.
A quick clarification in the wording of your question. By the time your code executes the file upload has already happened. The file resides in a temporary directory on the ColdFusion server and the form field related to the file upload contains the temporary filename for that file. Aside from checking to see if a file has been specified, do not do anything directly with that file or you'll be circumventing some built in security.
You want to use the cffile tag with the upload action (or equivalent udf) to move the temp file into a folder of your choosing. At that point you get access to a structure containing lots of information. Usually I "upload" into a temporary directory for the application, which should be outside of the webroot for security.
At this point you'll then want to do any validation against the file, such as filename length, file type, file size, etc and delete the file if it fails any checks. If it passes all checks then you move it into it's final destination which may be inside the webroot.
In your case you'll want to check the cffile structure element clientFile which is the original filename including extension (which you'll need to check, since an extension doesn't need to be present and can be any length).