Questions tagged [file-manipulation]
219 questions
1
vote
3 answers
Copying files from a series of directories based off a list in a text file
I am attempting to use either rsync or cp in a for loop to copy files matching a list of 200 of names stored on new lines in a .txt file that match filenames with the .pdbqt extension that are in a series of subdirectories with one parent folder.…

proteinmodels
- 13
- 5
1
vote
0 answers
Renaming Files in a Directory From List using R
I want to use a csv file with old file names and their new file names to rename files in a directory using R. I am quite the amateur in R but I'm hoping someone can help.
I've tried to create two character vectors with the names to compare. I…

Mission Critical Dev
- 11
- 2
1
vote
1 answer
Writeline() add empty line at end of file [Python]
This is my code to delete last line of file but after rewriting it to the same file there is an extra empty line that exist.
lines = open('file.csv', 'r').readlines()
del lines[-1]
open('file.csv', 'w').writelines(lines)
Notice that initial file…

bumbumpaw
- 2,522
- 1
- 24
- 54
1
vote
2 answers
manipulate bulk of 1000+ images
Hi all
I will be glad to get some help with windows batch script file to manipulate images,
I am migrating from old software, it used to save the files in folder and each file had its own user id (e.g. 10050.jpg)
I have like 1000 of these images, I…

JavaSheriff
- 7,074
- 20
- 89
- 159
1
vote
2 answers
How can I delete a file that doesn't have a matching file with a different extension
It's a bit hard to expliain, but I'm looking for a relatively easy bash script that can delete a file if it doesn't find a file of the same name that is an mp4.
Essentially I have files like:
S01E02 - Name of Episode 2.description
S01E02 - Name of…

Zach Dokuchic
- 13
- 5
1
vote
1 answer
Python Pandas: Compare two CSV files and delete lines from both the file by matching a column
We need to delete lines from both of the files if the value of the first column is not present in the other file.
Lets consider two CSV files:
file1.csv:
yrdi_391 111 1.11 1.0 1.1 111.0
yfyrn_9132 222 2.22 2.0 2.2 …

RandomCoder
- 79
- 1
- 7
1
vote
4 answers
awk/sed solution for printing only next line after it matches a pattern
I have multiple files in a folder. This is how a file look like
File1.txt
ghfgh gfghh
dffd kjkjoliukjkj
sdf ffghf
sf 898575
sfkj utiith
##
my data to be extracted
I want to extract the line immediately below "##" pattern from all the…

akang
- 566
- 2
- 15
1
vote
2 answers
Linux File Manipulation
I have been trying to manipulate a file using tr and have a task on removing all punctuation in one file and moving the contents into another.
cat file1 | tr --delete [:punct:] | cp file1 file2
When this command is used I'm returned with a preview…

Samuel Langley
- 19
- 1
1
vote
1 answer
How to delete a file from the working directory in Julia?
How do I delete a file from my current directory in Julia?
Is there a direct function like file.remove() in R?

Ashrith Reddy
- 1,022
- 1
- 13
- 26
1
vote
1 answer
Call a PHP file from another one multiple times (+ file reading)
What I am trying to do is read a value from blankVoteOB.txt, delete the value and repeat this process multiple times.
blankVote.php
global $cur_random;
for ($i=0; $i<2; $i++){
include 'readWriteRandomBV.php';
$random[$i]=$cur_random;
…

Mag
- 89
- 1
- 11
1
vote
0 answers
Remove a block of code present in a file inside curly braces in UNIX
I have a file from which I want to remove a block of code present inside { }. I tried using the command sed '/method2/,/}/d' filename.txt but the problem I have is I have other } inside the block I want to remove and my command removes only till the…

MasterOfNone
- 11
- 1
1
vote
1 answer
How to use "append" command on specific position in a text file using Visual Basic?
Text file:
test1
test2
test3
test4
I want to write after "test2" - something.
I tried first time to open the file and I read the position where is test2. After that I opened the text file in Append format but I don't know how to write on specific…

Pop Adrian
- 11
- 1
- 5
1
vote
0 answers
How to filter Unicode characters
I have a file containing a list of Unicode characters which (due to a copy paste fail) also has the hex code every 16 characters e.g.
Ս Վ Տ 0550 Ր Ց Ւ Փ Ք Օ Ֆ ՙ ՚ ՛ ՜ ՝ ՞ ՟ 0560 ՠ ա բ գ
with the 0550 and 0560in the middle. I want to make a…

caird coinheringaahing
- 998
- 1
- 14
- 27
1
vote
3 answers
Copy files from multiple folders with including folder name in Linux
I have multiple sub folders e.g.:
ls ./
F1 F2 F5 F8 F12 ...
Each folder contain file "file.txt"
How to copy all file.txt files to main folder containing folder name?
cp ./F1/file.txt ./file_1.txt
cp ./F2/file.txt ./file_2.txt
...

Pasi
- 181
- 2
- 7
1
vote
1 answer
Row manipulation in files, bash
I have a file called SSH which contains two lines of information. It looks like this:
src=192.168.60.111 ttl: 64 last_seen: 4295187854 oldest_pkt: 16 4295157111, 4295168442, 4295172078, 4295172078, 4295172328, 4295172328, 4295172829, 4295172829,…

Louise
- 63
- 2
- 9