How to show/modify the source directories dbx searches? - dbx

dbx keeps complaining it can't find the source code. How can i show/modify the source code directories dbx searches when looking for source file?

(dbx) help use
use
use { + | | '[' = ']' } ...
Set the list of directories to be searched when looking
for source files. If no argument is specified, the current
list if directories to be searched is displayed.

Related

Recursively appending names of all files in a directory with exif specific png meta data field (aesthetic_score) with linux / EXIFtool

I am trying to rename all files located in a directory (recursively) with a specific meta data field appended to the end of the png file name.
the meta data field name is "aesthetic_score" with a value range from 1.0-9.0
when I type:
exiftool -Aesthetic_score -G1 -s testn.png
the result is:
[PNG] Aesthetic_score : 7.0
This is how I would like to append the png files recursively within a directory.
Note i would like to swap out the word aesthetic with the word chad in the append, and not all files will have this data field:
input file:
filename001.png (metadata aesthetic_score:7.0)
output:
filename001-chad-score-70.png
I tried to use Digikam and JExifToolGui-2.01, without success.
I am trying to perform this task in the cmd line, although other solutions are welcome. Thank you for your help.
So, this might work for you, I can't really test it; note that you would need to get rid of the echo before the mv for it to actually do something (rename rather than just show what it would do).
while read name
do
newname=$(exiftool -G1 -s "$name"|awk '$2~/FileName/{name=$4}; $2~/Aesthetic_score/{basename=gensub(/^(.+)\....$/,"\\1","1",name);ext=gensub(/^.*\.(...)$/,"\\1","1",name);gsub(/\./,"",$4);print basename"."$4"."ext}')
echo mv "$name" "$newname"
done <<<$( find -iname \*.png )
Basically the find at the very end finds all the pngs.
The while loop takes every name find throws it, and passes each file through exiftool (using your specs) and parses the output using awk, which then outputs the new name, which gets captured in the shell variable by the same name.
And finally the mv (without the echo) renames the files.

Coping ClearCase with label history

I got a task to copy files with certain extensions from clear case while I need to :
find all files with certain extension and their map
copy the mapping but replace the file with a dir that has it's name
copy the file labels history to that dir
So I know what do to separately but can't figure how to connect things:
Code I used :
# for the latest label :
find . -name '*.extension' | cpio -pdm /path/to/save # this helped me to copy all files and their dir map
# to copy all labels for that file
\cp -r filename.extension##/main/ /path/to/save # the ##main/ gives me the view of the labels
and their map
The "map file" is more seen on Windows with a type manager
The map file, located in the ccase-home-dir\lib\mgrs directory, associates type manager methods with the programs that carry them out.
A map file entry has three fields: type manager, method, and program.
On Linux:
On UNIX, and Linux a type manager is a collection of programs in a subdirectory of ccase-home-dir /lib/mgrs; the subdirectory name is the name by which the type manager is specified with the –manager option in a mkeltype command.
Each program in a type manager subdirectory implements one method (data-manipulation operation).
A method can be a compiled program, a shell script, or a link to an executable.
This differs from your "dir map".
You can list labels on the current version with: cleartool descr -fmt "%l" myFile.
Using extended paths can work in a dynamic view, but it is best (to get all labels on all branches) to do a:
cleartool find . -version "!lbtype(x)" -name "yourelement" -exec "cleartool descr -fmt \"%n labels:%l\n\" \"%CLEARCASE_XPN%\""
To combine both code, do a loop on the result of the first find command.
# Make sure globstar is enabled
shopt -s globstar
for i in **/*.extension; do # Whitespace-safe and recursive
cpio -pdm "${i}" /path/to/save
cp -r "${i}"##/main/ /path/to/save
done

How to find string in file within current directory?

Is it possible to search within a directory to scan all files for a particular string, then return the file(s) if the string is found?
For example I am looking to try find files where "120854" is found. If we take the below example using a directory called /users/TCP/ that contains two files called File1 and File2.
File1
-----
Product1:432153
Product2:8614
Product3:975
File2
-----
Product76:87
Product324:684
Product965:120854
The expected outcome would return /users/TCP/File2 as "120854" is found on line 3 in that file. Obviously the directory I'm using has thousands of files and therefore wondering if this is possible. Can't find anything online myself
Thanks!
grep -Ril "120854" /users/TCP/
-- R stands for recursive.
-- i stands for ignore case (optional in your case).
-- l stands for "show the file name, not the result itself".
-- /users/TCP/ stands for directory you are searching in

Is there a way to undo a batch-rename of file extensions?

Ok so I kinda dropped the ball. I was trying to understand how things work. I had a few html files on my computer that I was trying to rename as txt files. This was strictly a learning exercise. Following the instructions I found here using this code:
for file in *.html
do
mv "$file" "${file%.html}.txt"
done
produced this error:
mv: rename *.html to *.txt: No such file or directory
Long story short I ended up going rogue and renaming the html files, as well as a lot of other non html files as txt files. So now I have files labeled like
my_movie.mp4.txt
my_song.mp3.txt
my_file.txt.txt
This may be a really dumb question but.. Is there a way to check if a file has two extensions and if yes remove the last one? Or any other way to undo this mess?
EDIT
Doing this find . -name "*.*.txt" -exec echo {} \; | cat -b seems to tell me what was changed and where it is located. The cat -b part is not necessary but I like it. This still doesn't fix what I broke though.
I'm not sure if terminal can check for extensions "twice", but you can check for . in every name an if there's more than one occurence of ., then your file has more extensions. Then you can cut the extension off with finding first occurence of . in a string when going backwards... or last one if checking characters in string in a normal way.
I have a faster option for you if you can use python. You can strip the extension with:
for file in list_of_files:
os.rename(file,os.path.splitext(file)[0])
which can give you from your file.txt.txt your file.txt
Example:
You wrote that your command tells you what has changed, so just take those changed files and dump them into a file(path to file per line). Then you can easily run this:
with open('<path to list>') as f:
list_of_files = f.readlines()
for file in list_of_files:
os.rename(file.strip('\n'), os.path.splitext(file.strip('\n'))[0])
If not, then you'd need to get the list from python:
import os
results = []
for root, folder, filenames in os.walk(<your path to folder>):
for filename in filenames:
if filename.endswith('.txt.txt'):
results.append(os.path.join(root, filename))
With this you got a list of files ending with .txt.txt like this <your folder>\\<path_to_file>.
Get a path to your directory used in os.walk() without folder's name(it's already in list) so it'll be like this:
e.g. os.walk('/home/me/directory') -> path='/home/me/' and res is item already in a list, which looks like directory/...
for res in results:
path = '' # set the path here
file = os.path.join(path,r)
os.rename(file, os.path.splitext(file)[0])
Depending on what files you want to find change .txt.txt in if filename.endswith('...') to whatever you like and os.rename() will take file's name without extension which in your case means it strips the additional extension you don't want to have.

Unix: finding a string within a directory and listing only its associated file names

I have been working on this for quite some time and decided to ask for some help. I'm trying to use a command to find a multiple occurrences of a function (basically a string) within a directory (that has multiple files) and would like to view only the file names which the string is found.
Lets say this was the directory I want to search filled with multiple .h and .cpp files is:
~/Project/Files
and I was looking for occurrences of a function called 'doThis'
So far I have tried:
grep -r doThis ~/Project/Files
But I get the path and where it occurs in the file, I only need the file names.
Also grep -f wont work because I get an error message saying "No such file or directory" and when using just grep I get an error message saying "path is a directory"
Any help would be great: Thanks guys!
Simply use the -l switch ;)
So :
grep -rl foobar dir

Resources