DATA data_tab TYPE solix_tab.
DATA filename TYPE string.
DATA path TYPE string DEFAULT 'C:\Users\path\to\my\file.pdf'.
cl_gui_frontend_services=>gui_upload( EXPORTING filename = path )
filetype = 'BIN'
CHANGING data_tab = data_tab ).
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = path
IMPORTING
stripped_name = filename
EXCEPTIONS
x_error = 1
OTHERS = 2.
DATA(file_extension) = /iwwrk/cl_mgw_workflow_rt_util=>get_extention_from_file_name( filename ).
DATA(mimetype) = /iwwrk/cl_mgw_workflow_rt_util=>get_mime_type_from_extension( file_extension ).
Tag: filename
[Terminal] Bash script to add leading season and episode numbers by parsing from file names
I had some videos in the format “My Episode #01.mkv” which I wanted to rename to “S01E01 My Episode #01.mkv“. This little script did the job for me:
# Specify the directory containing the files. For current directory use: $(dirname "$0")
directory="/path/to/your/directory"
# Loop through all .mkv files in the directory
for file in "$directory"/*.{webm,mkv}; do
# Check if the file exists to avoid errors when no files match
[ -e "$file" ] || continue
# Extract the base filename (without the directory path)
filename=$(basename "$file")
# Use regex to find the episode number (e.g., #01, #02)
if [[ $filename =~ \#([0-9]+) ]]; then
episode_number=${BASH_REMATCH[1]}
# Pad the episode number with a leading zero if it's a single digit
if [ ${#episode_number} -eq 1 ]; then
episode_number="0$episode_number"
fi
# Construct the new filename
new_filename="S01E${episode_number} $filename"
# Rename the file
mv "$file" "$directory/$new_filename"
echo "Renamed: $filename -> $new_filename"
fi
done
[ABAP] Replace unusual characters with ordinary characters in a String
DATA(unusual) = 'á Ă é Ä Ö Ü ä ö ü ß'.
DATA(pretty) = VALUE string( ).
CALL FUNCTION 'SCP_REPLACE_STRANGE_CHARS'
EXPORTING
intext = unusual
IMPORTING
outtext = pretty.
WRITE / unusual.
WRITE / pretty. "a A e Ae Oe Ue ae oe ue ss
[PDF.js] Set filename when downloading pdf
When using a blob or base64 data to open a file in PDF.js, the viewer is not able to get the correct filename. So when downloading the pdf using the download button inside the viewer, it will always download as document.pdf
. To manually set a filename, you can use the setTitleUsingUrl
function.
<iframe id="pdf-js-viewer" src="/pdf/web/viewer.html?file=" title="webviewer" frameborder="0" width="100%" height="700" allowfullscreen="" webkitallowfullscreen=""/>
let pdfViewerIFrame = document.getElementById("pdf-js-viewer")
pdfViewerIFrame.contentWindow.PDFViewerApplication.setTitleUsingUrl("myFilename")
More info here: https://github.com/mozilla/pdf.js/issues/10435