Ubuntu :: Bash Script To Name File After Folder?
Jun 7, 2011Question for people good with Bash scripts.
In a script, how do you name a file after a folder?
For example code...
Question for people good with Bash scripts.
In a script, how do you name a file after a folder?
For example code...
I need this script but I don't know how to do it I have one folder with several folders inside.On each folder a have one MKV or AVI file inside...What I need is a script to change the "modification date" of each folder to the "modification date" of each MKV or AVI that the folder has inside.
View 16 Replies View RelatedI'm starting bash shell script and I'm looping without any solution.
I'm trying to find some files under a folder hierarchy and in case of errors moving these files to a destination folder under the same hierarchy recreating this hierarchy if not exists.
Finding all ._* files under /src and moving them to /dest recreating folder1 or the others which contains ._* files but without moving files which does not correspond to the pattern.
Code:
I tried find command and I'am getting all needed files
Code:
But I don't know how to use the output to get the parent folder of files which are found to
1- create folder with mkdir -p /dest/folder1 or /dest/folder1/folder4
2- move found files from /src/... to /dest/... with rm command
I'm working on a find command as this trying to do all in the same line but ... little lost
Code:
When I position icons on the desktop in specific places, then I choose to move a file or folder into another folder, all the icons arrange back to the left side. This happened in an earlier version of KDE 4.x, disappeared the next version, and reappeared. how to keep this from happening. It makes using the desktop a pain in the you know what.
View 2 Replies View RelatedAfter upgrading to 11.04, I noticed something strange, being that when I want to drag a file or folder from one Nautilus folder window to another which is not visible, I can no longer hold the item over said folder's taskbar button and wait for it to appear. It just shows the + for copy, and when I let go (which I have no choice but to eventually do), it creates a launcher to that item (I assume it's doing that, and not actually copying there, but the + has me unsure).
I've looked in Nautilus's preferences to see if this is some new behaviour that I can revert back to, but could find nothing there.
I'm of course using the Classic desktop with bottom panel being the taskbar. If you know how I can rectify this, please let me know, as the times I would want to create a file or folder launcher without the usual hassle would be rare, but I am constantly dragging stuff from one folder to another, and it would be a real pain to have to line up source and destination folders each time.
I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END
[code]...
this is posable but am trying to do this "Create folder from a filename and move the file into the folder" i have 500000+ file's i need to do with is there a easy way?I really don't want to download them all make/move them with filemonkey just to re-upload them
View 2 Replies View Relatedi am trying to install a driver for my belkin wireless usb adapter but when i type make it says cannot find lib/modules/<debian version>/build so it does not configure the sources.
View 1 Replies View RelatedWhen i want copy a file or folder in some system folder like sbin,Etc.show me error about privilage but when I'm in console i use su command for become admin and i can copy my file or folder.in other operation system like windows user can copy anything,i want know for direct copy my folder in linux without console what should i do? i must join my user name in root group?
View 4 Replies View RelatedI been using linux for a while, but I havent had the time to really learn it. Something Id like to get more familiar with is bash so here is a simple example of something I would like to do:
I have a directory full of files. For each file in the directory create a new subdirectory with each files name.
I tried this:
#im already in this directory
aaa=./*
for a in $aaa
do mkdir $a
done
One of the problems is that there are spaces () and - in the filenames so I get many subfolders with names like "-" which i don't want.
I tried stuff like:
aaa=./*
for a in $aaa
do mkdir "'"$a"'"
done
This of course also did not work.
Additional I tried just creating a folder with the name of one of the files and I got this:
mkdir: cannot create directory `(audio) - R56339.EXE': File exists
Well yeah a file exsists with that name, but I want to create a folder- why is there a conflict?
Just to be clear here are the contents of this folder:
~/Desktop/LAB/Media/Drivers - (Image Deployment)/Optiplex_GX260/XP> ls
(audio) - R56339.EXE (NIC-Onboard-Intel) - R54402.EXE
(Modem-datafax-V92) - R54403.EXE OEM_Applications
[Code].....
I created a little bash script for renaming files from a folderEvery time i hv to put that bash script file (rename.sh) in folder Is there any ways i will call (rename.sh) from terminal without moving rename.sh into any folder ?ne More Question : Whenever i run any .sh file automatically one .sh~ file created it is my programing mistake or is it exists ?
View 7 Replies View RelatedI install nfs-common,nfs-kernel-serverNow I can not use
PHP Code:
# home 192.168.1.10(ro,no_root_squash)
I get
Quote:
bash: syntax error near unexpected token `('
when I want to share a folder
I want to delete all files within a specific folder without actually deleting the folder, what is a good bash command for this?. I found this one but encountered some errors even though I am executing it within the specific folder:
useratdebian:/home/user/folder# find . -type f -exec rm -rf {} ;
[1] 5052
useratdebian:/home/user/folder# find: missing argument to `-exec'
[1]+ Exit 1 find . -type f -exec rm -rf
The command as it appears is:
find . -type f -exec rm -rf {} ;
how to delete only the files contained within the folder called "folder" for example?
there is a folder. Its empty. When every I drag a new file and put into it it echo out "there is file in there" and keep monitoring the folder. How can I do it?
View 7 Replies View RelatedIs there a way to customize bash autocomplete such that it avoids searching for commands? I want it to auto complete file and folder names only!
View 2 Replies View RelatedI am new to Linux and I wanted to setup a dedicated game server on my notebook.
I've installed Ubuntu 9.04. I than created a directory named /home/phlex/kfserver. I downloaded the application binary from Steam. I changed the file permission with chmod +x hldsupdatetool.bin and now the file attributes are -rwxr-xr-x.
The problem is when I try to run the binary file. If I type ./hldsupdatetool.bin I get an error message "-bash: ./hldsupdatetool.bin: No such file or directory. It seems the OS can't find the file. I've downloaded the file several times thinking it may have been corrupt but it's not. I can delete the file, I can rename it and so the file is there. Sometimes Linux can be aggravating to use.
I have recently switched to using LXDE on my PC and I am on the whole pretty pleased with it. However,PCMan is giving me a really odd problem. Some of the files/folders are being displayed in the wrong order where they contain numbers. They are being ordered by their first digit not the whole number.
[Code]...
I have been messing with diff and grep for 2 days now without result
I am trying to match a file consisting of words to many separate other wordfiles in a specific directory. one by one.
What i want the script to do is to report how many matching words my main file has with every file in the directory, each in turn
setup:
Each of em are plain text files with 1 word per line
Output should be something like:
SCRIPT REPORT:
I am supposed to take some small files, and print them to a specific printer, such that the small files are concatenated into one file. The file name has to be included in the file that gets printed.
Should I be looking to concatenate the files into one file with the file names included, and then print them?
something like: -printfunction -printername < file*
How can I check and set who can view or open a given folder or file?
View 1 Replies View RelatedInitially I thought - use a for loop with ls in it:
Code:
However this causes lots of problems (folders have extensions, I have duplicate folders, the names with spaces create a folder for each element of the name).
The contents of the folder is basically movies (some with subtitles). Some of the names have things like (original) or CD1 CD2 in them.
What's the easiest way for me to make a program that requests a file location and then tar balls it. I basically want to start making a simple method of using pv with tar (lzma).
View 8 Replies View RelatedI have a folder that I don't know why becomes a file and now I can't open it. Can I do somthing to convert again into a folder. I thinking about commands like chmod somthing like that.
View 5 Replies View RelatedIs their a way, or a script/command that can move files into their own folder, naming the folder the same name as the file?
View 1 Replies View RelatedI had netbeans installed and I removed it using wheris netbeans and then sudo rm whatever files it gave.I also remember doing sudo rm -r /usr/lib/netbeans6.9 I did this because i wanted to install netbeans via the repo. Now I installed netbeans suing
Code:
varun@varun:~$ sudo apt-get install netbeans
and when I try running netbeans i get...
Code:
varun@varun:~$ netbeans
/bin/bash: : No such file or directory
Have i changed permissions or something?
I have a dell precision m4300 laptop with a 360 wireless bluetooth dell adapter On my system there is a debian lenny with kde3 and backported enable(everythings is p to date except bluez-utils and bluetooth holded at version 3.36-3)
Nowadays bluetooth more less works fine, I can send and receive single file to/from my phone (nokia n70)
The hell begin when I try to browse my phone files from konqueror...with bluetooth:/ I can see the list of all the device near me with sdp://[address]/ i can see two icons (obex file transfer & obex object push)
but I cant see or access to any file or folder into the phone.
I also try to update my bluez-utils to 4.60-1~bpo50+1 but in this case kbluetooth totally fail and a see the contextual menu of the system tray icon all disaled.
This is probably a very simple question and answer, so here goes... Doing the basic:
Code:
rm -fv -R "FILE1" "FILE2" "FILE3" "FILE4" "FOLDER" "FILE_WHATEVER"
...works just fine, but I would like to know if there is a way to only remove if the files are actually there. Currently, I know of this format, which works just fine:
[Code]...
...however, it seems to only work one file/folder at a time. Is there a way to modify it: I tried this, but it didn't seem to work:
[Code]...
I want to do a specific task for each file in a specific directory. First I want to see if I can list them with:
Code:
#!/bin/bash
for filename in `pwd`
[code]...
if I can create a bash script that once executer will edit or replace a line a in a file this line is the first one and its just one character that needs to be changed from a 1 to a 0.
How do I go about this? it is for a game called EVE Online, heres what my .sh look like atm
#!/bin/sh
echo fixing prefs.ini
#fix for prefs goes here
echo starting eve
eve
SO I'm not talking about changing the file permissions, The only thing I could find on google was this [URL]Basically can you convert your bash script into a executable file, One that you can't open in text editor?
View 2 Replies View Related