Questions tagged [basename]

51 questions
632
votes
14 answers

Get name of current script in Python

I'm trying to get the name of the Python script that is currently running. I have a script called foo.py and I'd like to do something like this in order to get the script name: print(Scriptname)
SubniC
  • 9,807
  • 4
  • 26
  • 33
21
votes
3 answers

How to find basename of path via pipe

This doesn't work: find "$all_locks" -mindepth 1 -maxdepth 1 -type d | basename apparently basename cannot read from stdin - in any case basename requires at least one argument.
user5047085
3
votes
3 answers

A fast and proper way to get the basename of a directory or a file in bash

I have this code: get_base() { echo "${1##*/}"; } And this works fine until we have 1 or more trailing slashes I have found a solution on how to fix it, but the problem is that we'll need extglob enabled, and I don't want that: ari@ari-gentoo ~ %…
Ari157
  • 95
  • 4
  • 16
3
votes
4 answers

Pipe the output of basename to string substitution

I need the basename of a file that is given as an argument to a bash script. The basename should be stripped of its file extension. Let's assume $1 = "/somefolder/andanotherfolder/myfile.txt", the desired output would be "myfile". The current…
stee
  • 101
  • 7
2
votes
3 answers

remove file extension with basename when using xargs

I would like to use xargs to run a command on a number of files where the output from the command has a different file extension. For the example below I am using echo as a dummy command. ls *.las | xargs -I % -n1 -P 10 echo $(basename %…
kungphil
  • 1,759
  • 2
  • 18
  • 27
2
votes
2 answers

basename of file with a leading - (dash)

I have a problem with basename in a zsh script. Imagine $directory containing a file name with a leading dash, in my case it's "-Fast-". Then the script executes folder=$(basename "$directory") or if I try the other syntax of …
phototrek
  • 23
  • 2
2
votes
3 answers

Shell Script to extract only file name

I have file format like this (publishfile.txt) drwxrwx---+ h655201 supergroup 0 2019-04-24 09:16 /data/xyz/invisible/se/raw_data/OMEGA drwxrwx---+ h655201 supergroup 0 2019-04-24 09:16 …
Shivam Sharma
  • 517
  • 1
  • 5
  • 19
1
vote
1 answer

React Hash Router v6 with basename

I need to use a hash router with a basename. I did this with the createHashRouter (React Router 6.8), with the basename property to render the app in the sub-route. When I open /sub/route in the browser I get the empty page though, only css…
1
vote
0 answers

Rename files with different suffixes with only one new suffix

I am trying to modify a pipeline for viral taxonomy analysis. In this pipeline, the variables R1 and R2 are the two input paired-end fastq files. But theses files can be .fastq.gz or .fq.gz. After trimming of these fastq files with the program…
ltalignani
  • 11
  • 2
1
vote
1 answer

React BrowserRouter not working after build

I have a static html website, and I want to embed a small React app inside a div on one of its pages (portfolio.html). My approach was to use create-react-app to create the widget, npm run build, and dump the build folder into my websites /static…
1
vote
3 answers

Get 'basename' from 'glob'

Directory path "/home/PPP/main/windows/agile/cmPvt" has aaa, bbb, ccc, ddd as its contents. Code Snippet: use File::Basename; my $kkLoc = ("/home/PPP/main/windows/agile/cmPvt"); my @kkarray = glob("$kkLoc/*") if (-e $kkLoc); foreach my $kknum…
PPP
  • 329
  • 1
  • 9
1
vote
1 answer

Powershell script to zip folder base on their name with the command compress-archive

I'm trying to compress each folder in my directory into a zip with the same name I tried the simple compress-archive command Compress-Archive $targetFolderPath -Destination $zipFolder -Update but it gives me only one zip named ".zip" with all my…
1
vote
2 answers

The method 'basename' isn't defined for the type 'Path'. (Documentation)

This is the Error when u are uploading files to firestore firebase. So I sol this Error. Checkout the answer below in Answers section. Thanks
kamran khan
  • 597
  • 3
  • 10
1
vote
1 answer

How to get the basename of multiple file with the filename pattern in linux docker container

I have multiple files with the same name pattern in a directory in my container folder: /report/tsl_report_20210604.csv /report/tsl_report_20210604.zip I am trying to list down and get the basename. So ouput should be…
Manish
  • 1,274
  • 3
  • 22
  • 59
1
vote
1 answer

GH Pages shows my homepage, but not any of my other paths

(Repo Link) (live link) Been struggling with gh-pages and react for a couple days now banging out my portfolio to display from the url; works perfectly fine on localhost. I got it to the point where the first page will show up just fine, but…
1
2 3 4