Questions tagged [file-manipulation]

219 questions
0
votes
0 answers

How can I get all the folders inside my current directory and access their data with javascript?

I have a directory containing a bunch of folders, all having an html,css and js file inside. I need some way to get like an array of all of these folder in order to access their data and using it in another html file using javascript. ex: this is my…
RANDOM NAME
  • 41
  • 1
  • 6
0
votes
2 answers

PHP - can my script for fetching filenames and finding new files be faster?

I have FTP access to 1 directory that holds all images for all products of the vendor. 1 product has multiple images: variations in size and variations in display of the product. There is no "list" (XML, CSV, database..) by which I am able to know…
Oktarin
  • 57
  • 2
  • 11
0
votes
0 answers

How to open and navigate through Windows folders using Python?

I would like to know how can I open and navigate through folders in the OS in Python the same way I can do it in MATLAB. I have tried using some os functions but none of them seems to make a lot of sense for what I need. Basically, I need a code…
0
votes
1 answer

replace first character of each line in file python

I am trying to replace some of the first characters in lines from multiple txt files and have this code but the output is wrong: for filename in glob.glob('./labels/**/*.txt', recursive=True): with open(filename, 'r') as f: original_lines =…
0
votes
2 answers

How to manipulate text file in C++

I have a txt file with the following data (inputFile.txt): Start FX FX FX FX End What I am trying to achieve is to have the FX replaced by TL and BQ so that I have both repeated equally 4 times as the number of FX. See below (expected result -…
Tee
  • 385
  • 3
  • 14
0
votes
0 answers

How to cast string to byte like object

I am trying to make a python script that encodes any file into a txt file. So far I can encode an input file into a txt file that contains the original files name, content and a sha hash for integrity checking (if you wish I can dump the code so far…
0
votes
1 answer

Remove Thumbnail from MP3 FILE - from yt-audio

When using yt-audio, how can you remove the thumbnail image (artwork / screenshot) that comes with the downloaded mp3 file? Best would be to have a way of doing it by adding an additional argument to the command, but looping through the downloaded…
David
  • 139
  • 1
  • 1
  • 12
0
votes
1 answer

Renaming Files By Adding Numbers Prefixes In File Names

I have a list of files which have number prefixes e.g 1-filename.txt 2-filename.txt ..so on . I found that I skipped a file name as 45-filename.txt . I have files from 1-filename.txt to 100-filename.txt in that directories . Now I want to rearrange…
ITGUYAKAY
  • 1
  • 1
0
votes
0 answers

Use file pointer in insert mode, not overwrite mode in PHP

I have noticed that in PHP (7.x), when you write to a file, it overwrites any existing characters. For example, $file = fopen("test.txt", "r+"); /* test.txt contains abc123 */ fwrite($file, "~"); /* test.txt now…
Lakshya Raj
  • 1,669
  • 3
  • 10
  • 34
0
votes
1 answer

PowerShell - Why is this not renaming my files?

I have been looking around for a way to quickly and easily rename hundreds os files in one go. something where I only have to change smalle parts for it to be reused somewhere else. So i ended up starting to make this script. shown below... the…
0
votes
1 answer

python loadtxt from many files, appending into the same numpy arrays

I'm new to python and want the most pythonic way of solving the following basic problem: I have many plain-text data files file.00001, file.00002, ..., file.99999 and each file has a single line, with numeric data stored in e.g. four columns. I want…
jms547
  • 201
  • 3
  • 11
0
votes
4 answers

How can I print the line index of a specific word in a text file?

I was trying to find a way to print the biggest word from a txt file, it's size and it's line index. I managed to get the first two done but can't quite figure it out how to print the line index. Can anyone help me? def BiggestWord(): list_words…
0
votes
1 answer

Do I need to sanitize $_SERVER['argv']? How?

I tested my PHP application for vulnerabilities, with Checkmarx. I got File Manipulation error in $_SERVER['argv']. $argv = $_SERVER['argv']; if (count($argv) < 3) { echo "Usage: ".htmlentities($argv[0])." OldName NewName\n"; exit(1); } Do…
Maximious
  • 155
  • 2
  • 12
0
votes
2 answers

How to remove duplicates in my python script?

I have used a regex search to filter down some results from a text file (searching for ".js") which has given me roughly around 16 results some of which are duplicates. I want to remove duplicates from that output and print either onto the console…
danjl
  • 3
  • 1
0
votes
2 answers

CheckMarx - File Manipulation Vulnerability - php

my code essentially takes a file uploaded to the server using a front end, by referring to the the $_FILES variable in php, and moves it to a new file on the server . Following snippet summarizes the code, $acutal_file =…